Create an ISBN png and sideload it into WordPress

@param string $isbn_number

@throws \Exception

@return string
765529
public function createBarcode( $isbn_number ) {

		if ( ! $this->validateIsbnNumber( $isbn_number ) ) {
			\Pressbooks\add_error( __( 'There was a problem creating the barcode: Invalid ISBN number.', 'pressbooks' ) );
			return false;
		}

		$this->isbnNumber = $this->fixIsbnNumber( $isbn_number );

		$ps = \Pressbooks\Utility\create_tmp_file();
		$png = \Pressbooks\Utility\create_tmp_file();

		$this->compile( $ps );
		$this->gs( $ps, $png, $this->dpi );
		$this->crop( $png );

		$old_id = \Pressbooks\Image\attachment_id_from_url( get_option( 'pressbooks_cg_isbn' ) );
		if ( $old_id ) {
			wp_delete_attachment( $old_id, true );
		}

		if ( ! function_exists( 'media_handle_sideload' ) ) {
			require_once( ABSPATH . 'wp-admin/includes/image.php' );
			require_once( ABSPATH . 'wp-admin/includes/file.php' );
			require_once( ABSPATH . 'wp-admin/includes/media.php' );
		}

		$pid = media_handle_sideload(
			[
				'name' => "{$this->isbnNumber}.png",
				'tmp_name' => $png,
			], 0
		);
		if ( is_wp_error( $pid ) ) {
			throw new \Exception(
				$pid->get_error_message()
			);
		}

		$src = wp_get_attachment_url( $pid );

		if ( false === $src ) {
			throw new \Exception( 'No attachment url.' );
		}

		update_option( 'pressbooks_cg_isbn', $src );

		return $src;
	}
1288445
public function isbn10($isbn)
    {
        if(is_string($isbn) === false) {
            throw new Exception('Invalid parameter type.');
        }

        //Verify ISBN-10 scheme
        $isbn = $this->hyphens->removeHyphens($isbn);
        if (strlen($isbn) != 10) {
            return false;
        }
        if (preg_match('/\d{9}[0-9xX]/i',$isbn) == false) {
            return false;
        }

        //Verify checksum
        $check = 0;
        for ($i = 0; $i < 10; $i++) {
            if (strtoupper($isbn[$i]) === 'X') {
                $check += 10 * intval(10 - $i);
            } else {
                $check += intval($isbn[$i]) * intval(10 - $i);
            }
        }
        return $check % 11 === 0;
    }
1346160
public function addHyphens($isbn, $char = '-')
    {
        if(is_string($isbn) === false ||
            is_string($char) === false) {
            throw new Exception('Invalid parameter type.');
        }
        
        $this->isbn = $isbn;
        $this->isbnSplit = array();
        
        if (strlen($this->isbn) === 13) {
            $this->isbnSplit[0] = substr($this->isbn, 0, 3);
        }

        $this->getRegistrationGroupElement();
        $this->getRegistrantElement();
        $this->getPublicationElement();
        $this->getCheckDigit();
        return implode($char, $this->isbnSplit);
    }
694563
private function getRegistrantElement()
    {
        if (isset($this->isbnSplit[0]) === true) {
            $soFar = implode('-', $this->isbnSplit);
        } else {
            $soFar = '978-'.$this->isbnSplit[1];
        }

        switch ($soFar) {
            case '978-0':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "2279999", 3, 2);
                $this->range("2280000", "2289999", 4, 2);
                $this->range("2290000", "6389999", 3, 2);
                $this->range("6390000", "6398999", 4, 2);
                $this->range("6399000", "6399999", 7, 2);
                $this->range("6400000", "6479999", 3, 2);
                $this->range("6480000", "6489999", 7, 2);
                $this->range("6490000", "6549999", 3, 2);
                $this->range("6550000", "6559999", 4, 2);
                $this->range("6560000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9499999", 6, 2);
                $this->range("9500000", "9999999", 7, 2);
                break;
            case '978-1':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "3999999", 3, 2);
                $this->range("4000000", "5499999", 4, 2);
                $this->range("5500000", "7319999", 5, 2);
                $this->range("7320000", "7399999", 7, 2);
                $this->range("7400000", "7749999", 5, 2);
                $this->range("7750000", "7753999", 7, 2);
                $this->range("7754000", "8697999", 5, 2);
                $this->range("8698000", "9729999", 6, 2);
                $this->range("9730000", "9877999", 4, 2);
                $this->range("9878000", "9989999", 6, 2);
                $this->range("9990000", "9999999", 7, 2);
                break;
            case '978-2':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "3499999", 3, 2);
                $this->range("3500000", "3999999", 5, 2);
                $this->range("4000000", "4899999", 3, 2);
                $this->range("4900000", "4949999", 6, 2);
                $this->range("4950000", "6999999", 3, 2);
                $this->range("7000000", "8399999", 4, 2);
                $this->range("8400000", "8999999", 5, 2);
                $this->range("9000000", "9197999", 6, 2);
                $this->range("9198000", "9198099", 5, 2);
                $this->range("9198100", "9199429", 6, 2);
                $this->range("9199430", "9199689", 7, 2);
                $this->range("9199690", "9499999", 6, 2);
                $this->range("9500000", "9999999", 7, 2);
                break;
            case '978-3':
                $this->range("0000000", "0299999", 2, 2);
                $this->range("0300000", "0339999", 3, 2);
                $this->range("0340000", "0369999", 4, 2);
                $this->range("0370000", "0399999", 5, 2);
                $this->range("0400000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9499999", 6, 2);
                $this->range("9500000", "9539999", 7, 2);
                $this->range("9540000", "9699999", 5, 2);
                $this->range("9700000", "9899999", 7, 2);
                $this->range("9900000", "9949999", 5, 2);
                $this->range("9950000", "9999999", 5, 2);
                break;
            case '978-4':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9499999", 6, 2);
                $this->range("9500000", "9999999", 7, 2);
                break;
            case '978-5':
                $this->range("0000000", "0049999", 5, 2);
                $this->range("0050000", "0099999", 4, 2);
                $this->range("0100000", "1999999", 2, 2);
                $this->range("2000000", "4209999", 3, 2);
                $this->range("4210000", "4299999", 4, 2);
                $this->range("4300000", "4309999", 3, 2);
                $this->range("4310000", "4399999", 4, 2);
                $this->range("4400000", "4409999", 3, 2);
                $this->range("4410000", "4499999", 4, 2);
                $this->range("4500000", "6039999", 3, 2);
                $this->range("6040000", "6049999", 7, 2);
                $this->range("6050000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9099999", 6, 2);
                $this->range("9100000", "9199999", 5, 2);
                $this->range("9200000", "9299999", 4, 2);
                $this->range("9300000", "9499999", 5, 2);
                $this->range("9500000", "9500999", 7, 2);
                $this->range("9501000", "9799999", 4, 2);
                $this->range("9800000", "9899999", 5, 2);
                $this->range("9900000", "9909999", 7, 2);
                $this->range("9910000", "9999999", 4, 2);
                break;
            case '978-600':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "4999999", 3, 2);
                $this->range("5000000", "8999999", 4, 2);
                $this->range("9000000", "9867999", 5, 2);
                $this->range("9868000", "9929999", 4, 2);
                $this->range("9930000", "9959999", 3, 2);
                $this->range("9960000", "9999999", 5, 2);
                break;
            case '978-601':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "7999999", 4, 2);
                $this->range("8000000", "8499999", 5, 2);
                $this->range("8500000", "9999999", 2, 2);
                break;
            case '978-602':
                $this->range("0000000", "0799999", 2, 2);
                $this->range("0800000", "0899999", 4, 2);
                $this->range("0900000", "1099999", 4, 2);
                $this->range("1100000", "1199999", 4, 2);
                $this->range("1200000", "1399999", 4, 2);
                $this->range("1400000", "1499999", 5, 2);
                $this->range("1500000", "1699999", 4, 2);
                $this->range("1700000", "1799999", 5, 2);
                $this->range("1800000", "1899999", 5, 2);
                $this->range("1900000", "1999999", 5, 2);
                $this->range("2000000", "4999999", 3, 2);
                $this->range("5000000", "5399999", 5, 2);
                $this->range("5400000", "5999999", 4, 2);
                $this->range("6000000", "6199999", 5, 2);
                $this->range("6200000", "6749999", 4, 2);
                $this->range("6750000", "6999999", 4, 2);
                $this->range("7000000", "7499999", 5, 2);
                $this->range("7500000", "7999999", 4, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-603':
                $this->range("0000000", "0499999", 2, 2);
                $this->range("0500000", "4999999", 2, 2);
                $this->range("5000000", "7999999", 3, 2);
                $this->range("8000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-604':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "8999999", 2, 2);
                $this->range("9000000", "9799999", 3, 2);
                $this->range("9800000", "9999999", 4, 2);
                break;
            case '978-605':
                $this->range("0000000", "0099999", 0, 2);
                $this->range("0100000", "0299999", 2, 2);
                $this->range("0300000", "0399999", 3, 2);
                $this->range("0400000", "0999999", 2, 2);
                $this->range("1000000", "1999999", 3, 2);
                $this->range("2000000", "2399999", 4, 2);
                $this->range("2400000", "3999999", 3, 2);
                $this->range("4000000", "5999999", 4, 2);
                $this->range("6000000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-606':
                $this->range("0000000", "0999999", 3, 2);
                $this->range("1000000", "4999999", 2, 2);
                $this->range("5000000", "7999999", 3, 2);
                $this->range("8000000", "9099999", 4, 2);
                $this->range("9100000", "9199999", 3, 2);
                $this->range("9200000", "9749999", 5, 2);
                $this->range("9750000", "9999999", 3, 2);
                break;
            case '978-607':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "7499999", 3, 2);
                $this->range("7500000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-608':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "1999999", 2, 2);
                $this->range("2000000", "4499999", 3, 2);
                $this->range("4500000", "6499999", 4, 2);
                $this->range("6500000", "6999999", 5, 2);
                $this->range("7000000", "9999999", 1, 2);
                break;
            case '978-609':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-611':
                $this->range("0000000", "9999999", 0, 2);
                break;
            case '978-612':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "3999999", 3, 2);
                $this->range("4000000", "4499999", 4, 2);
                $this->range("4500000", "4999999", 5, 2);
                $this->range("5000000", "9999999", 2, 2);
                break;
            case '978-613':
                $this->range("0000000", "9999999", 1, 2);
                break;
            case '978-614':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-615':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "4999999", 3, 2);
                $this->range("5000000", "7999999", 4, 2);
                $this->range("8000000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 0, 2);
                break;
            case '978-616':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-617':
                $this->range("0000000", "4999999", 2, 2);
                $this->range("5000000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-618':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "4999999", 3, 2);
                $this->range("5000000", "7999999", 4, 2);
                $this->range("8000000", "9999999", 5, 2);
                break;
            case '978-619':
                $this->range("0000000", "1499999", 2, 2);
                $this->range("1500000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-620':
                $this->range("0000000", "9999999", 1, 2);
                break;
            case '978-621':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "3999999", 0, 2);
                $this->range("4000000", "5999999", 3, 2);
                $this->range("6000000", "7999999", 0, 2);
                $this->range("8000000", "8999999", 4, 2);
                $this->range("9000000", "9499999", 0, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-7':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "4999999", 3, 2);
                $this->range("5000000", "7999999", 4, 2);
                $this->range("8000000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 6, 2);
                break;
            case '978-80':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 6, 2);
                break;
            case '978-81':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 6, 2);
                break;
            case '978-82':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6899999", 3, 2);
                $this->range("6900000", "6999999", 6, 2);
                $this->range("7000000", "8999999", 4, 2);
                $this->range("9000000", "9899999", 5, 2);
                $this->range("9900000", "9999999", 6, 2);
                break;
            case '978-83':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "5999999", 3, 2);
                $this->range("6000000", "6999999", 5, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 6, 2);
                break;
            case '978-84':
                $this->range("0000000", "1299999", 2, 2);
                $this->range("1300000", "1399999", 4, 2);
                $this->range("1400000", "1499999", 3, 2);
                $this->range("1500000", "1999999", 5, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9199999", 4, 2);
                $this->range("9200000", "9239999", 6, 2);
                $this->range("9240000", "9299999", 5, 2);
                $this->range("9300000", "9499999", 6, 2);
                $this->range("9500000", "9699999", 5, 2);
                $this->range("9700000", "9999999", 4, 2);
                break;
            case '978-85':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "5439999", 3, 2);
                $this->range("5440000", "5479999", 4, 2);
                $this->range("5480000", "5499999", 5, 2);
                $this->range("5500000", "5999999", 4, 2);
                $this->range("6000000", "6999999", 5, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9249999", 6, 2);
                $this->range("9250000", "9449999", 5, 2);
                $this->range("9450000", "9599999", 4, 2);
                $this->range("9600000", "9799999", 2, 2);
                $this->range("9800000", "9999999", 5, 2);
                break;
            case '978-86':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "5999999", 3, 2);
                $this->range("6000000", "7999999", 4, 2);
                $this->range("8000000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 6, 2);
                break;
            case '978-87':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "3999999", 0, 2);
                $this->range("4000000", "6499999", 3, 2);
                $this->range("6500000", "6999999", 0, 2);
                $this->range("7000000", "7999999", 4, 2);
                $this->range("8000000", "8499999", 0, 2);
                $this->range("8500000", "9499999", 5, 2);
                $this->range("9500000", "9699999", 0, 2);
                $this->range("9700000", "9999999", 6, 2);
                break;
            case '978-88':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "3269999", 3, 2);
                $this->range("3270000", "3389999", 4, 2);
                $this->range("3390000", "5999999", 3, 2);
                $this->range("6000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9099999", 6, 2);
                $this->range("9100000", "9299999", 3, 2);
                $this->range("9300000", "9399999", 4, 2);
                $this->range("9400000", "9479999", 6, 2);
                $this->range("9480000", "9499999", 5, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-89':
                $this->range("0000000", "2499999", 2, 2);
                $this->range("2500000", "5499999", 3, 2);
                $this->range("5500000", "8499999", 4, 2);
                $this->range("8500000", "9499999", 5, 2);
                $this->range("9500000", "9699999", 6, 2);
                $this->range("9700000", "9899999", 5, 2);
                $this->range("9900000", "9999999", 3, 2);
                break;
            case '978-90':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "4999999", 3, 2);
                $this->range("5000000", "6999999", 4, 2);
                $this->range("7000000", "7999999", 5, 2);
                $this->range("8000000", "8499999", 6, 2);
                $this->range("8500000", "8999999", 4, 2);
                $this->range("9000000", "9099999", 2, 2);
                $this->range("9100000", "9399999", 0, 2);
                $this->range("9400000", "9499999", 2, 2);
                $this->range("9500000", "9999999", 0, 2);
                break;
            case '978-91':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "4999999", 2, 2);
                $this->range("5000000", "6499999", 3, 2);
                $this->range("6500000", "6999999", 0, 2);
                $this->range("7000000", "7999999", 4, 2);
                $this->range("8000000", "8499999", 0, 2);
                $this->range("8500000", "9499999", 5, 2);
                $this->range("9500000", "9699999", 0, 2);
                $this->range("9700000", "9999999", 6, 2);
                break;
            case '978-92':
                $this->range("0000000", "5999999", 1, 2);
                $this->range("6000000", "7999999", 2, 2);
                $this->range("8000000", "8999999", 3, 2);
                $this->range("9000000", "9499999", 4, 2);
                $this->range("9500000", "9899999", 5, 2);
                $this->range("9900000", "9999999", 6, 2);
                break;
            case '978-93':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "4999999", 3, 2);
                $this->range("5000000", "7999999", 4, 2);
                $this->range("8000000", "9499999", 5, 2);
                $this->range("9500000", "9999999", 6, 2);
                break;
            case '978-94':
                $this->range("0000000", "5999999", 3, 2);
                $this->range("6000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-950':
                $this->range("0000000", "4999999", 2, 2);
                $this->range("5000000", "8999999", 3, 2);
                $this->range("9000000", "9899999", 4, 2);
                $this->range("9900000", "9999999", 5, 2);
                break;
            case '978-951':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5499999", 2, 2);
                $this->range("5500000", "8899999", 3, 2);
                $this->range("8900000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-952':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "4999999", 3, 2);
                $this->range("5000000", "5999999", 4, 2);
                $this->range("6000000", "6599999", 2, 2);
                $this->range("6600000", "6699999", 4, 2);
                $this->range("6700000", "6999999", 5, 2);
                $this->range("7000000", "7999999", 4, 2);
                $this->range("8000000", "9499999", 2, 2);
                $this->range("9500000", "9899999", 4, 2);
                $this->range("9900000", "9999999", 5, 2);
                break;
            case '978-953':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "1499999", 2, 2);
                $this->range("1500000", "5099999", 3, 2);
                $this->range("5100000", "5499999", 2, 2);
                $this->range("5500000", "5999999", 5, 2);
                $this->range("6000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-954':
                $this->range("0000000", "2899999", 2, 2);
                $this->range("2900000", "2999999", 4, 2);
                $this->range("3000000", "7999999", 3, 2);
                $this->range("8000000", "8999999", 4, 2);
                $this->range("9000000", "9299999", 5, 2);
                $this->range("9300000", "9999999", 4, 2);
                break;
            case '978-955':
                $this->range("0000000", "1999999", 4, 2);
                $this->range("2000000", "3599999", 2, 2);
                $this->range("3600000", "3799999", 4, 2);
                $this->range("3800000", "3899999", 5, 2);
                $this->range("3900000", "4099999", 4, 2);
                $this->range("4100000", "4499999", 5, 2);
                $this->range("4500000", "4999999", 4, 2);
                $this->range("5000000", "5499999", 5, 2);
                $this->range("5500000", "7199999", 3, 2);
                $this->range("7200000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-956':
                $this->range("0000000", "0899999", 2, 2);
                $this->range("0900000", "0999999", 5, 2);
                $this->range("1000000", "1999999", 2, 2);
                $this->range("2000000", "5999999", 3, 2);
                $this->range("6000000", "6999999", 4, 2);
                $this->range("7000000", "9999999", 4, 2);
                break;
            case '978-957':
                $this->range("0000000", "0299999", 2, 2);
                $this->range("0300000", "0499999", 4, 2);
                $this->range("0500000", "1999999", 2, 2);
                $this->range("2000000", "2099999", 4, 2);
                $this->range("2100000", "2799999", 2, 2);
                $this->range("2800000", "3099999", 5, 2);
                $this->range("3100000", "4399999", 2, 2);
                $this->range("4400000", "8199999", 3, 2);
                $this->range("8200000", "9699999", 4, 2);
                $this->range("9700000", "9999999", 5, 2);
                break;
            case '978-958':
                $this->range("0000000", "5399999", 2, 2);
                $this->range("5400000", "5599999", 4, 2);
                $this->range("5600000", "5699999", 5, 2);
                $this->range("5700000", "5999999", 5, 2);
                $this->range("6000000", "7999999", 3, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-959':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "9999999", 5, 2);
                break;
            case '978-960':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6599999", 3, 2);
                $this->range("6600000", "6899999", 4, 2);
                $this->range("6900000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "9299999", 5, 2);
                $this->range("9300000", "9399999", 2, 2);
                $this->range("9400000", "9799999", 4, 2);
                $this->range("9800000", "9999999", 5, 2);
                break;
            case '978-961':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "5999999", 3, 2);
                $this->range("6000000", "8999999", 4, 2);
                $this->range("9000000", "9499999", 5, 2);
                $this->range("9500000", "9999999", 0, 2);
                break;
            case '978-962':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8699999", 5, 2);
                $this->range("8700000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-963':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-964':
                $this->range("0000000", "1499999", 2, 2);
                $this->range("1500000", "2499999", 3, 2);
                $this->range("2500000", "2999999", 4, 2);
                $this->range("3000000", "5499999", 3, 2);
                $this->range("5500000", "8999999", 4, 2);
                $this->range("9000000", "9699999", 5, 2);
                $this->range("9700000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-965':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "5999999", 3, 2);
                $this->range("6000000", "6999999", 0, 2);
                $this->range("7000000", "7999999", 4, 2);
                $this->range("8000000", "8999999", 0, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-966':
                $this->range("0000000", "1299999", 2, 2);
                $this->range("1300000", "1399999", 3, 2);
                $this->range("1400000", "1499999", 2, 2);
                $this->range("1500000", "1699999", 4, 2);
                $this->range("1700000", "1999999", 3, 2);
                $this->range("2000000", "2789999", 4, 2);
                $this->range("2790000", "2899999", 3, 2);
                $this->range("2900000", "2999999", 4, 2);
                $this->range("3000000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 4, 2);
                $this->range("9000000", "9099999", 5, 2);
                $this->range("9100000", "9499999", 3, 2);
                $this->range("9500000", "9799999", 5, 2);
                $this->range("9800000", "9999999", 3, 2);
                break;
            case '978-967':
                $this->range("0000000", "0099999", 2, 2);
                $this->range("0100000", "0999999", 4, 2);
                $this->range("1000000", "1999999", 5, 2);
                $this->range("2000000", "2499999", 4, 2);
                $this->range("2500000", "2999999", 0, 2);
                $this->range("3000000", "4999999", 3, 2);
                $this->range("5000000", "5999999", 4, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9899999", 3, 2);
                $this->range("9900000", "9989999", 4, 2);
                $this->range("9990000", "9999999", 5, 2);
                break;
            case '978-968':
                $this->range("0100000", "3999999", 2, 2);
                $this->range("4000000", "4999999", 3, 2);
                $this->range("5000000", "7999999", 4, 2);
                $this->range("8000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-969':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "2299999", 2, 2);
                $this->range("2300000", "2399999", 5, 2);
                $this->range("2400000", "3999999", 2, 2);
                $this->range("4000000", "7499999", 3, 2);
                $this->range("7500000", "9999999", 4, 2);
                break;
            case '978-970':
                $this->range("0100000", "5999999", 2, 2);
                $this->range("6000000", "8999999", 3, 2);
                $this->range("9000000", "9099999", 4, 2);
                $this->range("9100000", "9699999", 5, 2);
                $this->range("9700000", "9999999", 4, 2);
                break;
            case '978-971':
                $this->range("0000000", "0159999", 3, 2);
                $this->range("0160000", "0199999", 4, 2);
                $this->range("0200000", "0299999", 2, 2);
                $this->range("0300000", "0599999", 4, 2);
                $this->range("0600000", "4999999", 2, 2);
                $this->range("5000000", "8499999", 3, 2);
                $this->range("8500000", "9099999", 4, 2);
                $this->range("9100000", "9599999", 5, 2);
                $this->range("9600000", "9699999", 4, 2);
                $this->range("9700000", "9899999", 2, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-972':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5499999", 2, 2);
                $this->range("5500000", "7999999", 3, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-973':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "1699999", 3, 2);
                $this->range("1700000", "1999999", 4, 2);
                $this->range("2000000", "5499999", 2, 2);
                $this->range("5500000", "7599999", 3, 2);
                $this->range("7600000", "8499999", 4, 2);
                $this->range("8500000", "8899999", 5, 2);
                $this->range("8900000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-974':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 4, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9499999", 5, 2);
                $this->range("9500000", "9999999", 4, 2);
                break;
            case '978-975':
                $this->range("0000000", "0199999", 5, 2);
                $this->range("0200000", "2399999", 2, 2);
                $this->range("2400000", "2499999", 4, 2);
                $this->range("2500000", "5999999", 3, 2);
                $this->range("6000000", "9199999", 4, 2);
                $this->range("9200000", "9899999", 5, 2);
                $this->range("9900000", "9999999", 3, 2);
                break;
            case '978-976':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "5999999", 2, 2);
                $this->range("6000000", "7999999", 3, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-977':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "4999999", 3, 2);
                $this->range("5000000", "6999999", 4, 2);
                $this->range("7000000", "8499999", 3, 2);
                $this->range("8500000", "8999999", 5, 2);
                $this->range("9000000", "9999999", 2, 2);
                break;
            case '978-978':
                $this->range("0000000", "1999999", 3, 2);
                $this->range("2000000", "2999999", 4, 2);
                $this->range("3000000", "7999999", 5, 2);
                $this->range("8000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-979':
                $this->range("0000000", "0999999", 3, 2);
                $this->range("1000000", "1499999", 4, 2);
                $this->range("1500000", "1999999", 5, 2);
                $this->range("2000000", "2999999", 2, 2);
                $this->range("3000000", "3999999", 4, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-980':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "5999999", 3, 2);
                $this->range("6000000", "9999999", 4, 2);
                break;
            case '978-981':
                $this->range("0000000", "1699999", 2, 2);
                $this->range("1700000", "1999999", 5, 2);
                $this->range("2000000", "2999999", 3, 2);
                $this->range("3000000", "3099999", 4, 2);
                $this->range("3100000", "3999999", 3, 2);
                $this->range("4000000", "9999999", 4, 2);
                break;
            case '978-982':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 2, 2);
                $this->range("9000000", "9799999", 4, 2);
                $this->range("9800000", "9999999", 5, 2);
                break;
            case '978-983':
                $this->range("0000000", "0199999", 2, 2);
                $this->range("0200000", "1999999", 3, 2);
                $this->range("2000000", "3999999", 4, 2);
                $this->range("4000000", "4499999", 5, 2);
                $this->range("4500000", "4999999", 2, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "8999999", 3, 2);
                $this->range("9000000", "9899999", 4, 2);
                $this->range("9900000", "9999999", 5, 2);
                break;
            case '978-984':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-985':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "5999999", 3, 2);
                $this->range("6000000", "8999999", 4, 2);
                $this->range("9000000", "9999999", 5, 2);
                break;
            case '978-986':
                $this->range("0000000", "1199999", 2, 2);
                $this->range("1200000", "5599999", 3, 2);
                $this->range("5600000", "7999999", 4, 2);
                $this->range("8000000", "9999999", 5, 2);
                break;
            case '978-987':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "1999999", 4, 2);
                $this->range("2000000", "2999999", 5, 2);
                $this->range("3000000", "3599999", 2, 2);
                $this->range("3600000", "3999999", 4, 2);
                $this->range("4000000", "4199999", 4, 2);
                $this->range("4200000", "4399999", 2, 2);
                $this->range("4400000", "4499999", 4, 2);
                $this->range("4500000", "4899999", 5, 2);
                $this->range("4900000", "4999999", 4, 2);
                $this->range("5000000", "8999999", 3, 2);
                $this->range("9000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-988':
                $this->range("0000000", "1199999", 2, 2);
                $this->range("1200000", "1499999", 5, 2);
                $this->range("1500000", "1699999", 5, 2);
                $this->range("1700000", "1999999", 5, 2);
                $this->range("2000000", "7699999", 3, 2);
                $this->range("7700000", "7999999", 5, 2);
                $this->range("8000000", "9699999", 4, 2);
                $this->range("9700000", "9999999", 5, 2);
                break;
            case '978-989':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5399999", 2, 2);
                $this->range("5400000", "5499999", 5, 2);
                $this->range("5500000", "7999999", 3, 2);
                $this->range("8000000", "9499999", 4, 2);
                $this->range("9500000", "9999999", 5, 2);
                break;
            case '978-9921':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "2999999", 0, 2);
                $this->range("3000000", "3999999", 2, 2);
                $this->range("4000000", "6999999", 0, 2);
                $this->range("7000000", "8999999", 3, 2);
                $this->range("9000000", "9699999", 0, 2);
                $this->range("9700000", "9999999", 4, 2);
                break;
            case '978-9922':
                $this->range("0000000", "1999999", 0, 2);
                $this->range("2000000", "2999999", 2, 2);
                $this->range("3000000", "5999999", 0, 2);
                $this->range("6000000", "7999999", 3, 2);
                $this->range("8000000", "8999999", 0, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9923':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "4999999", 2, 2);
                $this->range("5000000", "6999999", 0, 2);
                $this->range("7000000", "8999999", 3, 2);
                $this->range("9000000", "9699999", 0, 2);
                $this->range("9700000", "9999999", 4, 2);
                break;
            case '978-9924':
                $this->range("0000000", "2999999", 0, 2);
                $this->range("3000000", "3999999", 2, 2);
                $this->range("4000000", "4999999", 0, 2);
                $this->range("5000000", "6499999", 3, 2);
                $this->range("6500000", "8999999", 0, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9925':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5499999", 2, 2);
                $this->range("5500000", "7349999", 3, 2);
                $this->range("7350000", "9999999", 4, 2);
                break;
            case '978-9926':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "3999999", 2, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 4, 2);
                break;
            case '978-9927':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "3999999", 3, 2);
                $this->range("4000000", "4999999", 4, 2);
                $this->range("5000000", "9999999", 0, 2);
                break;
            case '978-9928':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "3999999", 3, 2);
                $this->range("4000000", "4999999", 4, 2);
                $this->range("5000000", "9999999", 0, 2);
                break;
            case '978-9929':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "5499999", 2, 2);
                $this->range("5500000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 4, 2);
                break;
            case '978-9930':
                $this->range("0000000", "4999999", 2, 2);
                $this->range("5000000", "9399999", 3, 2);
                $this->range("9400000", "9999999", 4, 2);
                break;
            case '978-9931':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9932':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8499999", 3, 2);
                $this->range("8500000", "9999999", 4, 2);
                break;
            case '978-9933':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9934':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "4999999", 2, 2);
                $this->range("5000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 4, 2);
                break;
            case '978-9935':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9936':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "3999999", 2, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 4, 2);
                break;
            case '978-9937':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "4999999", 2, 2);
                $this->range("5000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 4, 2);
                break;
            case '978-9938':
                $this->range("0000000", "7999999", 2, 2);
                $this->range("8000000", "9499999", 3, 2);
                $this->range("9500000", "9999999", 4, 2);
                break;
            case '978-9939':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9940':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "4999999", 2, 2);
                $this->range("5000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9941':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9942':
                $this->range("0000000", "7499999", 2, 2);
                $this->range("7500000", "8499999", 3, 2);
                $this->range("8500000", "8999999", 4, 2);
                $this->range("9000000", "9849999", 3, 2);
                $this->range("9850000", "9999999", 4, 2);
                break;
            case '978-9943':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "3999999", 3, 2);
                $this->range("4000000", "9749999", 4, 2);
                $this->range("9750000", "9999999", 3, 2);
                break;
            case '978-9944':
                $this->range("0000000", "0999999", 4, 2);
                $this->range("1000000", "4999999", 3, 2);
                $this->range("5000000", "5999999", 4, 2);
                $this->range("6000000", "6999999", 2, 2);
                $this->range("7000000", "7999999", 3, 2);
                $this->range("8000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-9945':
                $this->range("0000000", "0099999", 2, 2);
                $this->range("0100000", "0799999", 3, 2);
                $this->range("0800000", "3999999", 2, 2);
                $this->range("4000000", "5699999", 3, 2);
                $this->range("5700000", "5799999", 2, 2);
                $this->range("5800000", "8499999", 3, 2);
                $this->range("8500000", "9999999", 4, 2);
                break;
            case '978-9946':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9947':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-9948':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8499999", 3, 2);
                $this->range("8500000", "9999999", 4, 2);
                break;
            case '978-9949':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "3999999", 2, 2);
                $this->range("4000000", "6999999", 3, 2);
                $this->range("7000000", "7199999", 2, 2);
                $this->range("7200000", "7499999", 4, 2);
                $this->range("7500000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9950':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "8499999", 3, 2);
                $this->range("8500000", "9999999", 4, 2);
                break;
            case '978-9951':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8499999", 3, 2);
                $this->range("8500000", "9999999", 4, 2);
                break;
            case '978-9952':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "3999999", 2, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 4, 2);
                break;
            case '978-9953':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "3999999", 2, 2);
                $this->range("4000000", "5999999", 3, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9299999", 4, 2);
                $this->range("9300000", "9699999", 2, 2);
                $this->range("9700000", "9999999", 3, 2);
                break;
            case '978-9954':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "3999999", 2, 2);
                $this->range("4000000", "7999999", 3, 2);
                $this->range("8000000", "9899999", 4, 2);
                $this->range("9900000", "9999999", 2, 2);
                break;
            case '978-9955':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "9299999", 3, 2);
                $this->range("9300000", "9999999", 4, 2);
                break;
            case '978-9956':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9957':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "6499999", 3, 2);
                $this->range("6500000", "6799999", 2, 2);
                $this->range("6800000", "6999999", 3, 2);
                $this->range("7000000", "8499999", 2, 2);
                $this->range("8500000", "8799999", 4, 2);
                $this->range("8800000", "9999999", 2, 2);
                break;
            case '978-9958':
                $this->range("0000000", "0199999", 2, 2);
                $this->range("0200000", "0299999", 3, 2);
                $this->range("0300000", "0399999", 4, 2);
                $this->range("0400000", "0899999", 3, 2);
                $this->range("0900000", "0999999", 4, 2);
                $this->range("1000000", "1899999", 2, 2);
                $this->range("1900000", "1999999", 4, 2);
                $this->range("2000000", "4999999", 2, 2);
                $this->range("5000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9959':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9499999", 3, 2);
                $this->range("9500000", "9699999", 4, 2);
                $this->range("9700000", "9799999", 3, 2);
                $this->range("9800000", "9999999", 2, 2);
                break;
            case '978-9960':
                $this->range("0000000", "5999999", 2, 2);
                $this->range("6000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9961':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "6999999", 2, 2);
                $this->range("7000000", "9499999", 3, 2);
                $this->range("9500000", "9999999", 4, 2);
                break;
            case '978-9962':
                $this->range("0000000", "5499999", 2, 2);
                $this->range("5500000", "5599999", 4, 2);
                $this->range("5600000", "5999999", 2, 2);
                $this->range("6000000", "8499999", 3, 2);
                $this->range("8500000", "9999999", 4, 2);
                break;
            case '978-9963':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "2499999", 4, 2);
                $this->range("2500000", "2799999", 3, 2);
                $this->range("2800000", "2999999", 4, 2);
                $this->range("3000000", "5499999", 2, 2);
                $this->range("5500000", "7349999", 3, 2);
                $this->range("7350000", "7499999", 4, 2);
                $this->range("7500000", "9999999", 4, 2);
                break;
            case '978-9964':
                $this->range("0000000", "6999999", 1, 2);
                $this->range("7000000", "9499999", 2, 2);
                $this->range("9500000", "9999999", 3, 2);
                break;
            case '978-9965':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9966':
                $this->range("0000000", "1499999", 3, 2);
                $this->range("1500000", "1999999", 4, 2);
                $this->range("2000000", "6999999", 2, 2);
                $this->range("7000000", "7499999", 4, 2);
                $this->range("7500000", "9599999", 3, 2);
                $this->range("9600000", "9999999", 4, 2);
                break;
            case '978-9967':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9968':
                $this->range("0000000", "4999999", 2, 2);
                $this->range("5000000", "9399999", 3, 2);
                $this->range("9400000", "9999999", 4, 2);
                break;
            case '978-9970':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9971':
                $this->range("0000000", "5999999", 1, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-9972':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "1999999", 1, 2);
                $this->range("2000000", "2499999", 3, 2);
                $this->range("2500000", "2999999", 4, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9973':
                $this->range("0000000", "0599999", 2, 2);
                $this->range("0600000", "0899999", 3, 2);
                $this->range("0900000", "0999999", 4, 2);
                $this->range("1000000", "6999999", 2, 2);
                $this->range("7000000", "9699999", 3, 2);
                $this->range("9700000", "9999999", 4, 2);
                break;
            case '978-9974':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5499999", 2, 2);
                $this->range("5500000", "7499999", 3, 2);
                $this->range("7500000", "8799999", 4, 2);
                $this->range("8800000", "9099999", 3, 2);
                $this->range("9100000", "9499999", 2, 2);
                $this->range("9500000", "9999999", 2, 2);
                break;
            case '978-9975':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "2999999", 3, 2);
                $this->range("3000000", "3999999", 4, 2);
                $this->range("4000000", "4499999", 4, 2);
                $this->range("4500000", "8999999", 2, 2);
                $this->range("9000000", "9499999", 3, 2);
                $this->range("9500000", "9999999", 4, 2);
                break;
            case '978-9976':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "5999999", 4, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-9977':
                $this->range("0000000", "8999999", 2, 2);
                $this->range("9000000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-9978':
                $this->range("0000000", "2999999", 2, 2);
                $this->range("3000000", "3999999", 3, 2);
                $this->range("4000000", "9499999", 2, 2);
                $this->range("9500000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-9979':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "6499999", 2, 2);
                $this->range("6500000", "6599999", 3, 2);
                $this->range("6600000", "7599999", 2, 2);
                $this->range("7600000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9980':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "8999999", 2, 2);
                $this->range("9000000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-9981':
                $this->range("0000000", "0999999", 2, 2);
                $this->range("1000000", "1599999", 3, 2);
                $this->range("1600000", "1999999", 4, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9499999", 3, 2);
                $this->range("9500000", "9999999", 4, 2);
                break;
            case '978-9982':
                $this->range("0000000", "7999999", 2, 2);
                $this->range("8000000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-9983':
                $this->range("0000000", "7999999", 0, 2);
                $this->range("8000000", "9499999", 2, 2);
                $this->range("9500000", "9899999", 3, 2);
                $this->range("9900000", "9999999", 4, 2);
                break;
            case '978-9984':
                $this->range("0000000", "4999999", 2, 2);
                $this->range("5000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9985':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 4, 2);
                break;
            case '978-9986':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8999999", 3, 2);
                $this->range("9000000", "9399999", 4, 2);
                $this->range("9400000", "9699999", 3, 2);
                $this->range("9700000", "9999999", 2, 2);
                break;
            case '978-9987':
                $this->range("0000000", "3999999", 2, 2);
                $this->range("4000000", "8799999", 3, 2);
                $this->range("8800000", "9999999", 4, 2);
                break;
            case '978-9988':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5499999", 2, 2);
                $this->range("5500000", "7499999", 3, 2);
                $this->range("7500000", "9999999", 4, 2);
                break;
            case '978-9989':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "1999999", 3, 2);
                $this->range("2000000", "2999999", 4, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "9499999", 3, 2);
                $this->range("9500000", "9999999", 4, 2);
                break;
            case '978-99901':
                $this->range("0000000", "4999999", 2, 2);
                $this->range("5000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 2, 2);
                break;
            case '978-99902':
                $this->range("0000000", "9999999", 0, 2);
                break;
            case '978-99903':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99904':
                $this->range("0000000", "5999999", 1, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99905':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99906':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 2, 2);
                $this->range("9000000", "9499999", 2, 2);
                $this->range("9500000", "9999999", 3, 2);
                break;
            case '978-99908':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99909':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "9499999", 2, 2);
                $this->range("9500000", "9999999", 3, 2);
                break;
            case '978-99910':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99911':
                $this->range("0000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99912':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "5999999", 3, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99913':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "3599999", 2, 2);
                $this->range("3600000", "5999999", 0, 2);
                $this->range("6000000", "6049999", 3, 2);
                $this->range("6050000", "9999999", 0, 2);
                break;
            case '978-99914':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "6999999", 2, 2);
                $this->range("7000000", "7999999", 1, 2);
                $this->range("8000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99915':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99916':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "6999999", 2, 2);
                $this->range("7000000", "9999999", 3, 2);
                break;
            case '978-99917':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99918':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99919':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "3999999", 3, 2);
                $this->range("4000000", "6999999", 2, 2);
                $this->range("7000000", "7999999", 2, 2);
                $this->range("8000000", "8499999", 3, 2);
                $this->range("8500000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99920':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99921':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "6999999", 2, 2);
                $this->range("7000000", "7999999", 3, 2);
                $this->range("8000000", "8999999", 1, 2);
                $this->range("9000000", "9999999", 2, 2);
                break;
            case '978-99922':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "6999999", 2, 2);
                $this->range("7000000", "9999999", 3, 2);
                break;
            case '978-99923':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99924':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99925':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99926':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "5999999", 2, 2);
                $this->range("6000000", "8699999", 3, 2);
                $this->range("8700000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 2, 2);
                break;
            case '978-99927':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99928':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99929':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99930':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99931':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99932':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "5999999", 2, 2);
                $this->range("6000000", "6999999", 3, 2);
                $this->range("7000000", "7999999", 1, 2);
                $this->range("8000000", "9999999", 2, 2);
                break;
            case '978-99933':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99934':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99935':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 1, 2);
                $this->range("9000000", "9999999", 2, 2);
                break;
            case '978-99936':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99937':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99938':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5999999", 2, 2);
                $this->range("6000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 2, 2);
                break;
            case '978-99939':
                $this->range("0000000", "5999999", 1, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99940':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "6999999", 2, 2);
                $this->range("7000000", "9999999", 3, 2);
                break;
            case '978-99941':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99942':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99943':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99944':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99945':
                $this->range("0000000", "5999999", 1, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99946':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99947':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "6999999", 2, 2);
                $this->range("7000000", "9999999", 3, 2);
                break;
            case '978-99948':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99949':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99950':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99951':
                $this->range("0000000", "9999999", 0, 2);
                break;
            case '978-99952':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99953':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "7999999", 2, 2);
                $this->range("8000000", "9399999", 3, 2);
                $this->range("9400000", "9999999", 2, 2);
                break;
            case '978-99954':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "6999999", 2, 2);
                $this->range("7000000", "8799999", 3, 2);
                $this->range("8800000", "9999999", 2, 2);
                break;
            case '978-99955':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5999999", 2, 2);
                $this->range("6000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 2, 2);
                break;
            case '978-99956':
                $this->range("0000000", "5999999", 2, 2);
                $this->range("6000000", "8599999", 3, 2);
                $this->range("8600000", "9999999", 2, 2);
                break;
            case '978-99957':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9399999", 3, 2);
                $this->range("9400000", "9999999", 2, 2);
                break;
            case '978-99958':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "9399999", 2, 2);
                $this->range("9400000", "9499999", 3, 2);
                $this->range("9500000", "9999999", 3, 2);
                break;
            case '978-99959':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "5999999", 2, 2);
                $this->range("6000000", "9999999", 3, 2);
                break;
            case '978-99960':
                $this->range("0000000", "0999999", 1, 2);
                $this->range("1000000", "9499999", 2, 2);
                $this->range("9500000", "9999999", 3, 2);
                break;
            case '978-99961':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "3999999", 3, 2);
                $this->range("4000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99962':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99963':
                $this->range("0000000", "4999999", 2, 2);
                $this->range("5000000", "9199999", 3, 2);
                $this->range("9200000", "9999999", 2, 2);
                break;
            case '978-99964':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99965':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "3599999", 3, 2);
                $this->range("3600000", "6299999", 2, 2);
                $this->range("6300000", "9999999", 3, 2);
                break;
            case '978-99966':
                $this->range("0000000", "2999999", 1, 2);
                $this->range("3000000", "6999999", 2, 2);
                $this->range("7000000", "7999999", 3, 2);
                $this->range("8000000", "9699999", 2, 2);
                $this->range("9700000", "9999999", 3, 2);
                break;
            case '978-99967':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5999999", 2, 2);
                $this->range("6000000", "8999999", 3, 2);
                $this->range("9000000", "9999999", 0, 2);
                break;
            case '978-99968':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "5999999", 3, 2);
                $this->range("6000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99969':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99970':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99971':
                $this->range("0000000", "5999999", 1, 2);
                $this->range("6000000", "8499999", 2, 2);
                $this->range("8500000", "9999999", 3, 2);
                break;
            case '978-99972':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "8999999", 2, 2);
                $this->range("9000000", "9999999", 3, 2);
                break;
            case '978-99973':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99974':
                $this->range("0000000", "3999999", 0, 2);
                $this->range("4000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99975':
                $this->range("0000000", "3999999", 1, 2);
                $this->range("4000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99976':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "5999999", 2, 2);
                $this->range("6000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 0, 2);
                break;
            case '978-99977':
                $this->range("0000000", "1999999", 1, 2);
                $this->range("2000000", "3999999", 0, 2);
                $this->range("4000000", "6999999", 2, 2);
                $this->range("7000000", "7999999", 3, 2);
                $this->range("8000000", "9999999", 0, 2);
                break;
            case '978-99978':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '978-99979':
                $this->range("0000000", "4999999", 1, 2);
                $this->range("5000000", "7999999", 2, 2);
                $this->range("8000000", "9999999", 3, 2);
                break;
            case '979-10':
                $this->range("0000000", "1999999", 2, 2);
                $this->range("2000000", "6999999", 3, 2);
                $this->range("7000000", "8999999", 4, 2);
                $this->range("9000000", "9759999", 5, 2);
                $this->range("9760000", "9999999", 6, 2);
                break;
            case '979-11':
                $this->range("0000000", "2499999", 2, 2);
                $this->range("2500000", "5499999", 3, 2);
                $this->range("5500000", "8499999", 4, 2);
                $this->range("8500000", "9499999", 5, 2);
                $this->range("9500000", "9999999", 6, 2);
                break;
            case '979-12':
                $this->range("0000000", "1999999", 0, 2);
                $this->range("2000000", "2009999", 3, 2);
                $this->range("2010000", "9999999", 0, 2);
                break;
        }
    }
122208
public function validateIsbnNumber( $isbn_number ) {

		// Regex to split a string only by the last whitespace character
		@list( $isbn_number, $addon ) = preg_split( '/\s+(?=\S*+$)/', trim( $isbn_number ) ); // @codingStandardsIgnoreLine

		$is_valid_isbn = ( new \Isbn\Isbn() )->validation->isbn( $isbn_number );
		$is_valid_addon = true;

		if ( $addon ) {
			if ( ! preg_match( '/^([0-9]{2}|[0-9]{5})$/', $addon ) ) {
				$is_valid_addon = false;
			}
		}

		return $is_valid_isbn && $is_valid_addon;
	}
568492
protected function checkCharsAllowed() {
        $c = strlen($this->text);

        // Special case, if we have 10 digits, the last one can be X
        if ($c === 10) {
            if (array_search($this->text[9], $this->keys) === false && $this->text[9] !== 'X') {
                throw new CINParseException('isbn', 'The character \'' . $this->text[9] . '\' is not allowed.');
            }

            // Drop the last char
            $this->text = substr($this->text, 0, 9);
        }

        return parent::checkCharsAllowed();
    }
919254
public static function convertIsbn13to10(string $isbn) : string
    {
        if (substr($isbn, 0, 3) !== '978') {
            throw IsbnNotConvertibleException::forIsbn($isbn);
        }

        $isbn = substr($isbn, 3, 9);

        return $isbn . CheckDigit::calculateCheckDigit10($isbn);
    }
17477
public function format(string $isbn) : string
    {
        if ($this->cleanupBeforeValidate) {
            if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
                throw Exception\InvalidIsbnException::forIsbn($isbn);
            }

            $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
        }

        if (preg_match(Internal\Regexp::ISBN13, $isbn) === 1) {
            if ($this->validateCheckDigit) {
                if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
                    throw Exception\InvalidIsbnException::forIsbn($isbn);
                }
            }

            return Internal\RangeService::format($isbn);
        }

        $isbn = strtoupper($isbn);

        if (preg_match(Internal\Regexp::ISBN10, $isbn) === 1) {
            if ($this->validateCheckDigit) {
                if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
                    throw Exception\InvalidIsbnException::forIsbn($isbn);
                }
            }

            return Internal\RangeService::format($isbn);
        }

        throw Exception\InvalidIsbnException::forIsbn($isbn);
    }
542682
public function convertIsbn10to13(string $isbn) : string
    {
        if ($this->cleanupBeforeValidate) {
            if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
                throw Exception\InvalidIsbnException::forIsbn($isbn);
            }

            $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
        }

        $isbn = strtoupper($isbn);

        if (preg_match(Internal\Regexp::ISBN10, $isbn) === 0) {
            throw Exception\InvalidIsbnException::forIsbn($isbn);
        }

        if ($this->validateCheckDigit) {
            if (! Internal\CheckDigit::validateCheckDigit10($isbn)) {
                throw Exception\InvalidIsbnException::forIsbn($isbn);
            }
        }

        return Internal\Converter::convertIsbn10to13($isbn);
    }
319837
public function isValidIsbn13(string $isbn) : bool
    {
        if ($this->cleanupBeforeValidate) {
            if (preg_match(Internal\Regexp::ASCII, $isbn) === 0) {
                return false;
            }

            $isbn = preg_replace(Internal\Regexp::NON_ALNUM, '', $isbn);
        }

        if (preg_match(Internal\Regexp::ISBN13, $isbn) === 0) {
            return false;
        }

        if ($this->validateCheckDigit) {
            if (! Internal\CheckDigit::validateCheckDigit13($isbn)) {
                return false;
            }
        }

        return true;
    }
619540
protected function createBook() {
		$host = wp_parse_url( network_home_url(), PHP_URL_HOST );
		if ( is_subdomain_install() ) {
			$domain = $this->getSubdomainOrSubDirectory( $this->targetBookUrl ) . '.' . $host;
			$path = '/';
		} else {
			$domain = $host;
			$path = '/' . $this->getSubdomainOrSubDirectory( $this->targetBookUrl );
		}

		if ( ! $this->targetBookTitle ) {
			$this->targetBookTitle = $this->sourceBookMetadata['name'];
		}

		$user_id = get_current_user_id();
		// Disable automatic redirect to new book dashboard
		add_filter(
			'pb_redirect_to_new_book', function () {
				return false;
			}
		);
		// Remove default content so that the book only contains the results of the clone operation
		add_filter( 'pb_default_book_content', [ $this, 'removeDefaultBookContent' ] );
		$result = wpmu_create_blog( $domain, $path, $this->targetBookTitle, $user_id );
		remove_all_filters( 'pb_redirect_to_new_book' );
		remove_filter( 'pb_default_book_content', [ $this, 'removeDefaultBookContent' ] );
		if ( is_wp_error( $result ) ) {
			return false;
		}

		return $result;
	}
1329052
public function isValidIsbn(string $isbn) : bool
    {
        return $this->isValidIsbn10($isbn) || $this->isValidIsbn13($isbn);
    }
378563
public function get10()
    {
        // Is it valid?
        if ($this->isValid()) {
            // Is it already an ISBN-10?  If so, return as-is.
            if (strlen($this->raw) == 10) {
                return $this->raw;
            } elseif (strlen($this->raw) == 13
                && substr($this->raw, 0, 3) == '978'
            ) {
                // Is it a Bookland EAN?  If so, we can convert to ISBN-10.
                $start = substr($this->raw, 3, 9);
                return $start . self::getISBN10CheckDigit($start);
            }
        }

        // If we made it this far, conversion was not possible:
        return false;
    }
167099
public static function isValidISBN13($isbn)
    {
        $isbn = self::normalizeISBN($isbn);
        if (strlen($isbn) != 13) {
            return false;
        }
        return
            substr($isbn, 12) == self::getISBN13CheckDigit(substr($isbn, 0, 12));
    }
925972
public static function format(string $isbn) : string
    {
        $rangeInfo = self::getRangeInfo($isbn);

        if ($rangeInfo !== null && $rangeInfo->parts !== null) {
            return implode('-', $rangeInfo->parts);
        }

        return $isbn;
    }
912409
protected function createOEBPSGenerator( $book_contents, $metadata ) : \Generator {

		// First, setup and affect $this->stylesheet
		yield 10 => $this->generatorPrefix . __( 'Compiling styles', 'pressbooks' );
		$this->createStylesheet();

		// Reset manifest
		$this->manifest = [];

		/* Note: order affects $this->manifest */

		// Cover
		yield 15 => $this->generatorPrefix . __( 'Creating cover', 'pressbooks' );
		$this->createCover( $book_contents, $metadata );

		// Before Title Page
		$this->createBeforeTitle( $book_contents, $metadata );

		// Title
		yield 20 => $this->generatorPrefix . __( 'Creating title page', 'pressbooks' );
		$this->createTitle( $book_contents, $metadata );

		// Copyright
		yield 20 => $this->generatorPrefix . __( 'Creating copyright page', 'pressbooks' );
		$this->createCopyright( $book_contents, $metadata );

		// Dedication and Epigraph (In that order!)
		yield 25 => $this->generatorPrefix . __( 'Exporting dedication and epigraph', 'pressbooks' );
		$this->createDedicationAndEpigraph( $book_contents, $metadata );

		// Front-matter
		yield 30 => $this->generatorPrefix . __( 'Exporting front matter', 'pressbooks' );
		yield from $this->createFrontMatterGenerator( $book_contents, $metadata );

		// Promo
		$this->createPromo( $book_contents, $metadata );

		// Parts, Chapters
		yield 40 => $this->generatorPrefix . __( 'Exporting parts and chapters', 'pressbooks' );
		yield from $this->createPartsAndChaptersGenerator( $book_contents, $metadata );

		// Back-matter
		yield 50 => $this->generatorPrefix . __( 'Exporting back matter', 'pressbooks' );
		yield from $this->createBackMatterGenerator( $book_contents, $metadata );

		// Table of contents
		// IMPORTANT: Do this last! Uses $this->manifest to generate itself
		yield 70 => $this->generatorPrefix . __( 'Creating table of contents', 'pressbooks' );
		$this->createToc( $book_contents, $metadata );
	}
273545
protected function createToc( $book_contents, $metadata ) {

		$vars = [
			'post_title' => '',
			'stylesheet' => $this->stylesheet,
			'post_content' => '',
			'isbn' => ( isset( $metadata['pb_ebook_isbn'] ) ) ? $metadata['pb_ebook_isbn'] : '',
			'lang' => $this->lang,
		];

		// Start by inserting self into correct manifest position
		$array_pos = $this->positionOfToc();

		$file_id = 'table-of-contents';
		$filename = "{$file_id}.{$this->filext}";
		$vars['post_title'] = __( 'Table Of Contents', 'pressbooks' );

		$this->manifest = array_slice( $this->manifest, 0, $array_pos + 1, true ) + [
			$file_id => [
				'ID' => -1,
				'post_title' => $vars['post_title'],
				'filename' => $filename,
			],
		] + array_slice( $this->manifest, $array_pos + 1, count( $this->manifest ) - 1, true );

		// HTML

		$li_count = 0;
		$i = 1; // Chapter count
		$m = 1; // Part count
		$html = '<div id="toc"><h1>' . __( 'Contents', 'pressbooks' ) . '</h1><ul>';
		foreach ( $this->manifest as $k => $v ) {

			// We only care about front-matter, part, chapter, back-matter
			// Skip the rest

			$subtitle = '';
			$author = '';
			$license = '';
			$title = Sanitize\strip_br( $v['post_title'] );
			if ( preg_match( '/^front-matter-/', $k ) ) {
				$class = 'front-matter ';
				$class .= $this->taxonomy->getFrontMatterType( $v['ID'] );
				$subtitle = trim( get_post_meta( $v['ID'], 'pb_subtitle', true ) );
				$author = $this->contributors->get( $v['ID'], 'pb_authors' );
				$license = $this->doTocLicense( $v['ID'] );
			} elseif ( preg_match( '/^part-/', $k ) ) {
				$class = 'part';
				if ( get_post_meta( $v['ID'], 'pb_part_invisible', true ) === 'on' ) {
					$class .= ' display-none';
				} else {
					/**
					 * Filter the label used for post types (front matter/parts/chapters/back matter) in the TOC and section headings.
					 *
					 * @since 5.6.0
					 *
					 * @param string $label
					 * @param array $args
					 *
					 * @return string Filtered label
					 */
					$title = ( $this->numbered ? apply_filters( 'pb_post_type_label', __( 'Part', 'pressbooks' ), [ 'post_type' => 'part' ] ) . ' ' . \Pressbooks\L10n\romanize( $m ) . '. ' : '' ) . $title;
					$m++;
				}
			} elseif ( preg_match( '/^chapter-/', $k ) ) {
				$class = implode( ' ', [ 'chapter', $this->taxonomy->getChapterType( $v['ID'] ) ] );
				$subtitle = trim( get_post_meta( $v['ID'], 'pb_subtitle', true ) );
				$author = $this->contributors->get( $v['ID'], 'pb_authors' );
				$license = $this->doTocLicense( $v['ID'] );
				if ( $this->numbered && $this->taxonomy->getChapterType( $v['ID'] ) !== 'numberless' ) {
					$title = " $i. " . $title;
				}
				if ( $this->taxonomy->getChapterType( $v['ID'] ) !== 'numberless' ) {
					++$i;
				}
			} elseif ( preg_match( '/^back-matter-/', $k ) ) {
				$class = 'back-matter ';
				$class .= $this->taxonomy->getBackMatterType( $v['ID'] );
				$subtitle = trim( get_post_meta( $v['ID'], 'pb_subtitle', true ) );
				$author = $this->contributors->get( $v['ID'], 'pb_authors' );
				$license = $this->doTocLicense( $v['ID'] );
			} else {
				continue;
			}

			$html .= sprintf( '<li class="%s"><a href="%s"><span class="toc-chapter-title">%s</span>', $class, $v['filename'], Sanitize\decode( $title ) );

			if ( $subtitle ) {
				$html .= ' <span class="chapter-subtitle">' . Sanitize\decode( $subtitle ) . '</span>';
			}

			if ( $author ) {
				$html .= ' <span class="chapter-author">' . Sanitize\decode( $author ) . '</span>';
			}

			if ( $license ) {
				$html .= ' <span class="chapter-license">' . $license . '</span> ';
			}

			$html .= '</a>';

			if ( Export::shouldParseSubsections() === true && $class !== 'part' ) {
				$sections = Book::getSubsections( $v['ID'] );
				if ( $sections ) {
					$html .= '<ul class="sections">';
					foreach ( $sections as $id => $title ) {
						$html .= '<li class="section"><a href="' . $v['filename'] . '#' . $id . '"><span class="toc-subsection-title">' . Sanitize\decode( $title ) . '</span></a></li>';
					}
					$html .= '</ul>';
				}
			}

			$html .= "</li>\n";
			++$li_count;

		}
		if ( 0 === $li_count ) {
			$html .= '<li></li>';
		}
		$html .= "</ul></div>\n";

		// Create file

		$vars['post_content'] = $html;

		\Pressbooks\Utility\put_contents(
			$this->tmpDir . "/OEBPS/$filename",
			$this->loadTemplate( $this->dir . '/templates/epub201/html.php', $vars )
		);

	}