src/IsbnTools.php
public function convertIsbn13to10(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) === 0) {
            throw Exception\InvalidIsbnException::forIsbn($isbn);
        }

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

        return Internal\Converter::convertIsbn13to10($isbn);
    }
public function convertIsbn13to10(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) === 0) {
            throw Exception\InvalidIsbnException::forIsbn($isbn);
        }

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

        return Internal\Converter::convertIsbn13to10($isbn);
    }
public function convertIsbn13to10 ( 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 ) === 0 ) { throw Exception \ InvalidIsbnException :: forIsbn ( $ isbn ) ; } if ( $ this -> validateCheckDigit ) { if ( ! Internal \ CheckDigit :: validateCheckDigit13 ( $ isbn ) ) { throw Exception \ InvalidIsbnException :: forIsbn ( $ isbn ) ; } } return Internal \ Converter :: convertIsbn13to10 ( $ isbn ) ; }
Converts an ISBN-13 to an ISBN-10.

Only ISBN-13 numbers starting with 978 can be converted to an ISBN-10.
If the input ISBN is a valid ISBN-13 but does not start with 978, an exception is thrown.

@param string $isbn The ISBN-13 to convert.

@return string The converted, unformatted ISBN-10.

@throws Exception\InvalidIsbnException        If the ISBN is not a valid ISBN-13.
@throws Exception\IsbnNotConvertibleException If the ISBN cannot be converted.
Converts an ISBN - 13 to an ISBN - 10 .