This package can be used to:
- validate an ISBN code
- convert codes between ISBN-10, ISBN-13 and EAN (without hyphens) formats
- calculate the checksum digit
- show the registration agency (country or language)
Install with composer:
composer require biblys/isbn:^2.1.1
Use case: converting an EAN (9782843449499) to an ISBN-13 (978-2-84344-949-9).
<?php
use Biblys\Isbn\Isbn as Isbn;
$isbn = new Isbn('9782843449499');
try {
$isbn->validate();
$isbn13 = $isbn->format("ISBN-13");
echo "ISBN-13: $isbn13";
} catch(Exception $e) {
echo "An error occured while parsing $ean: ".$e->getMessage();
}
Run tests with PHPUnit:
composer install
composer test
Run tests in a docker container:
composer docker
New ISBN ranges may be added from time to time by the International ISBN Agency. Whenever it happens, this library must be updated. If a range update is necessary, please open an issue on Github. You can also open a pull request after updating the ranges your self with the following commands:
composer install
composer run update-ranges
- Upgrade dependencies
- Upgrade PHPUnit to 8.3
- Added a
validate
method that throws an Exception on ISBN validation errors - Fixed [#9] Improve error output
- Added composer scripts to run tests and update ranges in a Docker container
- Updated ISBN ranges
- Fixed #7: ISBNs with invalid product code or country code are considered valid
- Added PHP versions 7.1 & 7.2 to travis config file
- Attempts to format an invalid ISBN will now throw an Exception
- Fixed considering ISBNs with an invalid product code as valid
- Updated ISBN ranges
- Fixed #6: Error when validating ISBN-10 with X as a checksum digit
- Update ISBN ranges
- Fixed error when no rule is found (eg. for ISBN 9790706801940)
- Added 978-99978 range for Mongolia
- Fixed #3: Bug in the 978-613 range
- Added a composer script to update ISBN ranges from isbn-international.org
- Fixed #2: added LICENSE file and copyright information
- Added Travis configuration file
- Revamped library as a Composer package
- Fixed #1: ISBN-10 checksum character calculation
- Added phpunit tests
- Updated ISBN XML ranges file
- EAN-13 checksum character calculation bug fix
- First release