Ncda
extends Ark
in package
NOID Check digit algorithm (NCDA).
Methods for calculating and verifying check digits using the NOID Check Digit Algorithm.
Tags
Table of Contents
Methods
- areLexicalEquivalent() : bool
- Compare multiple ARKs for lexical equivalence
- calc() : string
- Calculate Check Digit.
- generate() : string
- Generate an ARK of desired length with given NAAN and character repetoire.
- normalize() : string
- Normalization for ARK.
- removeDuplicateChars() : string|array<string|int, string>
- Remove duplicate characters from repetoire.
- splitIntoComponents() : array<string|int, mixed>
- Split ARK into components.
- verify() : bool
- Verify ID.
Methods
areLexicalEquivalent()
Compare multiple ARKs for lexical equivalence
public
static areLexicalEquivalent(array<string|int, string> $arks) : bool
Checks if all ARKs in a list are lexically equivalent.
Parameters
- $arks : array<string|int, string>
-
List containing arks .
Tags
Return values
bool —True if all ARKs in list are lexically equivalent, false otherwise
calc()
Calculate Check Digit.
public
static calc(string $id, string $xdigits) : string
Calculates a check digit using the NOID Check Digit Algorithm.
Parameters
- $id : string
-
ID for which a checkdigit should be calculated.
- $xdigits : string
-
Character repetoire used for ID generation.
Tags
Return values
string —Returns check digit.
generate()
Generate an ARK of desired length with given NAAN and character repetoire.
public
static generate(string $naan, string $xdigits, int $length[, string $shoulder = null ][, string $nma = null ][, bool $ncda = true ][, bool $slashAfterLabel = false ]) : string
Parameters
- $naan : string
-
Name Assigning Authority Number.
- $xdigits : string
-
Charachter repetoire e.g. "0123456789bcdfghjkmnpqrstvwxz".
- $length : int
-
Desired length of ID.
- $shoulder : string = null
-
Prefix to blade (default: null).
- $nma : string = null
-
Name Mapping Authority (default: null).
- $ncda : bool = true
-
Executes Noid Check Digit Algorithm and appends result to blade (default: true).
- $slashAfterLabel : bool = false
-
Include / in label part e.g. ark:/ (default: false).
Tags
Return values
string —$id Generated ARK.
normalize()
Normalization for ARK.
public
static normalize(mixed $ark) : string
Reformats string containing an ARK into a normalized form.
Parameters
- $ark : mixed
-
ARK or URI containing an ARK.
Tags
Return values
stringremoveDuplicateChars()
Remove duplicate characters from repetoire.
public
static removeDuplicateChars(string $xdigits[, bool $sort = true ][, bool $arr = false ]) : string|array<string|int, string>
Duplicate characters get removed from given string.
Parameters
- $xdigits : string
-
String containing the character repetoire.
- $sort : bool = true
-
Sort the characters
- $arr : bool = false
-
Return the characters as array.
Tags
Return values
string|array<string|int, string>splitIntoComponents()
Split ARK into components.
public
static splitIntoComponents(string $ark) : array<string|int, mixed>
Splits an ARK into the following components: Resolver Service, NAAN, Base Name, Base Compact Name, Check Zone and Suffixes.
Parameters
- $ark : string
Tags
Return values
array<string|int, mixed> —In case of an invalid array, the returned array, will have empty values.
verify()
Verify ID.
public
static verify(string $id, string $xdigits) : bool
Verify a given ID against the Noid Check Digit Algorithm.
Parameters
- $id : string
-
ID whichs should be verified.
- $xdigits : string
-
Character repetoire used for ID generation.