Erc
extends Anvl
in package
Electronic Resource Citation (ERC).
Methods for creating and interacting with ERC records.
Tags
Table of Contents
Constants
- ENCODINGSCHEME = ["chr" => [' ', '!', '"', '#', '$', '&', '\'', '(', ')', '*', '+', ',', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '|'], "code" => ['%sp', '%ex', '%dq', '%ns', '%do', '%am', '%sq', '%op', '%cp', '%as', '%pl', '%co', '%pd', '%sl', '%cn', '%sc', '%lt', '%eq', '%gt', '%qu', '%at', '%ox', '%ls', '%cx', '%vb']]
Properties
- $record : array<string|int, mixed>
- $lineLength : int
Methods
- __construct() : mixed
- ERC Record.
- add() : void
- Add element.
- addComment() : void
- Add Comment
- addElement() : void
- Add Kernel element.
- addStory() : void
- Add story to record.
- decodeElementValue() : string
- Decode element value.
- decodeRecord() : string
- Decode record.
- encodeElementValue() : string
- Encode element value.
- isValidKernelElementLabel() : bool
- Check if string is valid kernel element label.
- isValidRecord() : bool
- Validate ERC record.
- parseRecord() : null|array<string|int, string>
- Parse ERC record to array.
- record() : string
- Retrieve record.
Constants
ENCODINGSCHEME
public
mixed
ENCODINGSCHEME
= ["chr" => [' ', '!', '"', '#', '$', '&', '\'', '(', ')', '*', '+', ',', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '|'], "code" => ['%sp', '%ex', '%dq', '%ns', '%do', '%am', '%sq', '%op', '%cp', '%as', '%pl', '%co', '%pd', '%sl', '%cn', '%sc', '%lt', '%eq', '%gt', '%qu', '%at', '%ox', '%ls', '%cx', '%vb']]
Properties
$record
public
array<string|int, mixed>
$record
$lineLength
protected
int
$lineLength
Methods
__construct()
ERC Record.
public
__construct([int $lineLength = 72 ]) : mixed
Parameters
- $lineLength : int = 72
-
After how many words to wrap text.
add()
Add element.
public
add(string $label[, string $value = '' ]) : void
Add a new data element to the ANVL record.
Parameters
- $label : string
-
1*<any CHAR, excluding control-chars and ":">
- $value : string = ''
-
text
addComment()
Add Comment
public
addComment(string $comment) : void
Parameters
- $comment : string
addElement()
Add Kernel element.
public
addElement(string $label, string $value) : void
Adds a Kernel element to the record.
Parameters
- $label : string
-
String beginning with a letter that may contain any combination of letters, numbers, hyphens, and underscores. An element label may also be accompanied by its coded synonym e. g. wer(h1)
- $value : string
-
Value of the element will be encoded.
addStory()
Add story to record.
public
addStory(array<string|int, string> $storyValues[, string $label = null ][, bool $append = true ]) : void
Parameters
- $storyValues : array<string|int, string>
-
e.g. ['Gibbon, Edward', 'The Decline and Fall of the Roman Empire', 1781, 'http://www.ccel.org/g/gibbon/decline/']
- $label : string = null
-
Story type e.g. 'about', 'neta', 'support', 'depositor'.
- $append : bool = true
-
Append to story instead of overwriting.
decodeElementValue()
Decode element value.
public
static decodeElementValue(string $value) : string
Parameters
- $value : string
-
String which should be decoded.
Tags
Return values
stringdecodeRecord()
Decode record.
public
static decodeRecord(string $record) : string
Gets
Parameters
- $record : string
-
String containing a valid ERC record.
Return values
stringencodeElementValue()
Encode element value.
public
static encodeElementValue(string $value) : string
Parameters
- $value : string
-
String which should be encoded.
Tags
Return values
stringisValidKernelElementLabel()
Check if string is valid kernel element label.
public
static isValidKernelElementLabel(string $label) : bool
Kernel element labels are strings beginning with a letter that may contain any combination of letters, numbers, hyphens, and underscores ("_"). An element label may also be accompanied by its coded synonym e. g. wer(h1).
Parameters
- $label : string
Return values
boolisValidRecord()
Validate ERC record.
public
static isValidRecord(string $record[, array<string|int, string> $labelList = null ]) : bool
Checks if string conforms to ERC.
Parameters
- $record : string
-
String to check.
- $labelList : array<string|int, string> = null
-
Optionally pass a list of allowed labels.
Return values
bool —Returns TRUE if record is valid.
parseRecord()
Parse ERC record to array.
public
static parseRecord(string $erc[, array<string|int, string> &$labelList = null ]) : null|array<string|int, string>
Parameters
- $erc : string
-
ERC record.
- $labelList : array<string|int, string> = null
-
Optionally pass a list of allowed labels.
Return values
null|array<string|int, string> —In case of a valid erc record, the parsed metadata is returned.
record()
Retrieve record.
public
record([bool $decode = true ][, bool $comments = false ]) : string
Parameters
- $decode : bool = true
-
Decode values.
- $comments : bool = false
-
Hide comments.