PHP code example of nicebooks / isbn

1. Go to this page and download the library: Download nicebooks/isbn library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nicebooks / isbn example snippets


use Nicebooks\Isbn\Isbn;

$isbn = Isbn::of('123456789X'); // will return an instance of Isbn10
$isbn = Isbn::of('9781234567897'); // will return an instance of Isbn13

Isbn10::of('123456789X'); // equivalent to Isbn::of('123456789X')->to10();
Isbn13::of('9781234567897'); // equivalent to Isbn::of('9781234567897')->to13();

Isbn::of('123456789X')->is10(); // true
Isbn::of('123456789X')->is13(); // false

Isbn::of('9781234567897')->is10(); // false
Isbn::of('9781234567897')->is13(); // true

Isbn::of('123456789X') instanceof Isbn10; // true
Isbn::of('9781234567897') instanceof Isbn13; // true

Isbn::of('123456789X')->to13(); // Isbn13 instance with value 9781234567897

Isbn::of('9781234567897')->to10(); // Isbn10 instance with value 123456789X

Isbn::of('9781234567897')->isConvertibleTo10(); // true
Isbn::of('9791234567896')->isConvertibleTo10(); // false

Isbn::of('123456789X')->isEqualTo(Isbn::of('9781234567897')); // true

Isbn::of('9781338878936')->getParts(); // ['978', '1', '338', '87893', '6']

Isbn::of('9781338878936')->getRegistrationGroup()->name; // 'English language'