ISBN
in package
ISBN Class
This class provides ISBN validation and conversion functionality.
Tags
Table of Contents
- $raw : string
- Raw ISBN string
- $valid : bool
- Validation status of ISBN (null until checked)
- __construct() : mixed
- Constructor
- get10() : mixed
- Get the ISBN in ISBN-10 format:
- get13() : mixed
- Get the ISBN in ISBN-13 format:
- getISBN10CheckDigit() : string
- Given the first 9 digits of an ISBN-10, generate the check digit.
- getISBN13CheckDigit() : string
- Given the first 12 digits of an ISBN-13, generate the check digit.
- isValid() : bool
- Is the current ISBN valid in some format? (May be 10 or 13 digit).
- isValidISBN10() : bool
- Is the provided ISBN-10 valid?
- isValidISBN13() : bool
- Is the provided ISBN-13 valid?
- normalizeISBN() : string
- Return the first sequence of at least 8 digits followed by an optional X.
Properties
$raw
Raw ISBN string
protected
string
$raw
$valid
Validation status of ISBN (null until checked)
protected
bool
$valid
= null
Methods
__construct()
Constructor
public
__construct(string $raw) : mixed
Parameters
- $raw : string
-
Raw ISBN string to convert/validate.
Return values
mixed —get10()
Get the ISBN in ISBN-10 format:
public
get10() : mixed
Return values
mixed —ISBN, or false if invalid/incompatible.
get13()
Get the ISBN in ISBN-13 format:
public
get13() : mixed
Return values
mixed —ISBN, or false if invalid/incompatible.
getISBN10CheckDigit()
Given the first 9 digits of an ISBN-10, generate the check digit.
public
static getISBN10CheckDigit(string $isbn) : string
Parameters
- $isbn : string
-
The first 9 digits of an ISBN-10.
Return values
string —The check digit.
getISBN13CheckDigit()
Given the first 12 digits of an ISBN-13, generate the check digit.
public
static getISBN13CheckDigit(string $isbn) : string
Parameters
- $isbn : string
-
The first 12 digits of an ISBN-13.
Return values
string —The check digit.
isValid()
Is the current ISBN valid in some format? (May be 10 or 13 digit).
public
isValid() : bool
Return values
bool —isValidISBN10()
Is the provided ISBN-10 valid?
public
static isValidISBN10(string $isbn) : bool
Parameters
- $isbn : string
-
The ISBN-10 to test.
Return values
bool —isValidISBN13()
Is the provided ISBN-13 valid?
public
static isValidISBN13(string $isbn) : bool
Parameters
- $isbn : string
-
The ISBN-13 to test.
Return values
bool —normalizeISBN()
Return the first sequence of at least 8 digits followed by an optional X.
public
static normalizeISBN(string $raw) : string
These ISBN characters may be separated by any number of '.', '-', '_' and whitespace characters; the separation characters are removed. A lower x is converted to an upper X.
Parameters
- $raw : string
-
ISBN to clean up.
Return values
string —Normalized ISBN.