Util
in package
Utilities for parsing MARC data.
Table of Contents
- chopTrailingPunctuation() : string
- Remove trailing punctuation typically found on subfield values.
- getLastArrayElement() : mixed
- Get the last array element. If not available, return the fallback value.
- parseEnumerationAndFirstPage() : array<string|int, mixed>
- Parse subfield $q (enumeration and first page) from field 773.
- parseRelatedParts() : array<string|int, mixed>
- Parse subfield $g (related parts) from 76X-78X fields.
- trimNonWordCharacters() : string
- Trim any non-word characters from the start or end of a string.
Methods
chopTrailingPunctuation()
Remove trailing punctuation typically found on subfield values.
public
static chopTrailingPunctuation(string $value) : string
Parameters
- $value : string
Return values
string —getLastArrayElement()
Get the last array element. If not available, return the fallback value.
public
static getLastArrayElement(array<string|int, mixed> $arr[, mixed $fallback = NULL ]) : mixed
Parameters
- $arr : array<string|int, mixed>
-
The array from which to get the last element.
- $fallback : mixed = NULL
-
The value to return if the array has no last element.
Return values
mixed —parseEnumerationAndFirstPage()
Parse subfield $q (enumeration and first page) from field 773.
public
static parseEnumerationAndFirstPage(string $message) : array<string|int, mixed>
Parameters
- $message : string
-
The string to parse.
Tags
Return values
array<string|int, mixed> —An array containing the separated info extracted from the subfield. Possible keys:
- volume
- part
- number
- page
parseRelatedParts()
Parse subfield $g (related parts) from 76X-78X fields.
public
static parseRelatedParts(string $message) : array<string|int, mixed>
Parameters
- $message : string
-
The string to parse.
Tags
Return values
array<string|int, mixed> —An array containing the separated info extracted from the subfield. Possible keys:
- date
- volume
- part
- number
- pages
trimNonWordCharacters()
Trim any non-word characters from the start or end of a string.
public
static trimNonWordCharacters(string $message) : string
This is useful for getting data from MARC subfields, which often look something like this: $aCongress on Machinability$d(1965 :$cRoyal Commonwealth Society) E.g. we would like to get "1965" for $d, not "(1965 :".
Parameters
- $message : string
-
The string to parse.
Return values
string —A new string, with leading and trailing non-word characters removed.