Coder Social home page Coder Social logo

isbn's Introduction

ISBN PHP library Build Status

This library is develop to provide all tools needed to handle ISBN (both ISBN-10 and ISBN-13) codes to PHP developers.

IMPORTANT NOTICE

dev-master is now pretty different from the 1.x version. If you want to stay with version 1.x, please use 1.0.0 or 1.0.x-dev or 1.x-dev.

Initialization

$isbn = new Isbn\Isbn();

Check

This function allows you to verify if an ISBN code is an ISBN-10 or ISBN-13. This does not verifies if the ISBN code is valid. To check if the ISBN code is valid, you can use the Validation class. Examples:

$isbn->check->is10('888183718'); // Will return false
$isbn->check->is13('9788889527191'); // Will return true
$isbn->check->is13('978888952719'); // Will return false
$isbn->check->identify('8881837188'); // Will return 10
$isbn->check->identify('888183718'); // Will return false
$isbn->check->identify('9788889527191'); // Will return 13
$isbn->check->identify('978888952719'); // Will return false

Validation

This class allows you to validate ISBN-10 and ISBN-13. Examples:

$isbn->validation->isbn('8881837188'); // Will return true
$isbn->validation->isbn('8881837187'); // Will return false
$isbn->validation->isbn('9788889527191'); // Will return true
$isbn->validation->isbn('9788889527190'); // Will return false
$isbn->validation->isbn10('8881837188'); // Will return true
$isbn->validation->isbn10('8881837187'); // Will return false
$isbn->validation->isbn13('9788889527191'); // Will return true
$isbn->validation->isbn13('9788889527190'); // Will return false

Hyphens

This class provides simple functions to work with hyphens.

Add Hyphens

This function allows you to put correct hyphens in ISBN-10 and ISBN-13. Examples:

echo $isbn->hyphens->addHyphens('9791090636071'); // Will return 979-10-90636-07-1

echo $hyphens->addHyphens('9791090636071', ' '); // Will return 979 10 90636 07 1

Remove Hyphens

This function allows you to remove hyphens from the ISBN-10 and ISBN-13. Examples:

$isbn->hyphens->removeHyphens('85 359 0277 5'); // Will return 8535902775
$isbn->hyphens->removeHyphens('0-943396-04-2'); // Will return 0943396042
$isbn->hyphens->removeHyphens('978 988 00 3827 3'); // Will return 9789880038273
$isbn->hyphens->removeHyphens('979-10-90636-07-1'); // Will return 9791090636071

Fix Hyphens

This function allows you to fix hyphens in ISBN-10 and ISBN-13

$isbn->hyphens->fixHyphens('85 35902 77 5', ' '); // Will return 85 359 0277 5
$isbn->hyphens->fixHyphens('0 943 3960 42'); // Will return 0-943396-04-2
$isbn->hyphens->fixHyphens('978 988 003827 3', ' '); // Will return 978 988 00 3827 3
$isbn->hyphens->fixHyphens('979-10906-36-07-1'); // Will return 979-10-90636-07-1

CheckDigit

This class allows you to calculate the check digit for ISBN-10 and ISBN-13. Examples:

$isbn->checkDigit->make('888183718'); // Will return 8
$isbn->checkDigit->make('978888952719'); // Will return 1
$isbn->checkDigit->make10('888183718'); // Will return 8
$isbn->checkDigit->make13('978888952719'); // Will return 1

Translate

This class allows you to convert ISBN-10 to ISBN-13 and back. Examples:

$isbn->translate->to13('8889527191'); // Will return 9788889527191
$isbn->translate->to10('9786028328227'); // Will return 6028328227

Develop this library

If you are interested in some new features please open a bug on GitHub. If you already have a patch available, please, open a pull request. Before opening a pull request, be sure that all tests are passed.

Tests

To check the tests run the following:

vendor/bin/phpunit tests

from the project root folder. If the folder vendor is empty or non-existing, run composer install or composer.phar install depending on your composer installation.

isbn's People

Contributors

fale avatar mejta avatar linkkingjay avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.