ARK Management Tools

Ncda extends Ark
in package

NOID Check digit algorithm (NCDA).

Methods for calculating and verifying check digits using the NOID Check Digit Algorithm.

Tags
link
https://metacpan.org/dist/Noid/view/noid#NOID-CHECK-DIGIT-ALGORITHM

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
link
https://www.ietf.org/archive/id/draft-kunze-ark-39.html#name-normalization-and-lexical-e.
example

$eq = Ark::areLexicalEquivalent(['ark:/ABC456/xyz?info', 'ARK:ABC456/xyz??']); var_dump($eq) // Outputs: bool(true)

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
link
https://metacpan.org/dist/Noid/view/noid#NOID-CHECK-DIGIT-ALGORITHM.
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
example

echo ARK::generate('12345', '0123456789bcdfghjkmnpqrstvwxz', 7, 'q1'); // Possible outputs: ark:12345/q15fk5zszx

Return values
string

$id Generated ARK.

removeDuplicateChars()

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
example

echo Ark::removeDuplicateChars('xyyyzaaabbc') // Outputs "abcxyz"

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
example

print_r(Ark::splitIntoComponents('https://n2t.org/ark:9999/q15fk5zszx/image.jpg?info')) // Outputs: ['resolverService' => 'https://n2t.org/', 'naan' => '9999', 'baseName' => '9999/q15fk5zszx', 'baseCompactName' => 'ark:9999/q15fk5zszx', 'checkZone' => 'ark:9999/q15fk5zszx', 'suffixes' => '', 'inflections' => []]

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.

Return values
bool

        
On this page

Search results