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