Chords

SongLyricsXmlParser
in package

Song lyrics XML parser.

Table of Contents

parse()  : SongLyrics
Parses song lyrics.
extractLabeledStrophes()  : array<string|int, Strophe>
Returns strophes with a label.
parseChord()  : Chord
Parses a chord.
parseLyrics()  : array<string|int, Node>
Parses song lyrics.
parseParagraph()  : Paragraph
Parses a paragraph.
parseRepeat()  : Strophe
Parses a repeat element.
parseStrophe()  : Strophe
Parses a strophe.
parseVerse()  : Verse
Parses a verse.

Methods

extractLabeledStrophes()

Returns strophes with a label.

private extractLabeledStrophes(SimpleXMLElement $sxml) : array<string|int, Strophe>

The keys of the returned array are strophe labels.

Parameters
$sxml : SimpleXMLElement

lyrics element

Tags
throws
InvalidXmlException
throws
InvalidArgumentException
throws
DomainException
Return values
array<string|int, Strophe>

labeled strophes

parseLyrics()

Parses song lyrics.

private parseLyrics(SimpleXMLElement $sxml, array<string|int, Strophe$labeledStrophes) : array<string|int, Node>
Parameters
$sxml : SimpleXMLElement

lyrics element

$labeledStrophes : array<string|int, Strophe>

already parsed strophes with labels

Tags
throws
InvalidXmlException
throws
InvalidArgumentException
throws
DomainException
Return values
array<string|int, Node>

lyrics content

parseParagraph()

Parses a paragraph.

private parseParagraph(SimpleXMLElement $sxml) : Paragraph
Parameters
$sxml : SimpleXMLElement

paragraph element

Tags
throws
InvalidXmlException
throws
InvalidArgumentException
throws
DomainException
Return values
Paragraph

parsed object

parseRepeat()

Parses a repeat element.

private parseRepeat(SimpleXMLElement $sxml, array<string|int, mixed> $context) : Strophe
Parameters
$sxml : SimpleXMLElement

repeat element

$context : array<string|int, mixed>

context where the repeat element appeared

Tags
throws
InvalidXmlException
throws
InvalidArgumentException
throws
DomainException
Return values
Strophe

parsed object

parseStrophe()

Parses a strophe.

private parseStrophe(SimpleXMLElement $sxml) : Strophe
Parameters
$sxml : SimpleXMLElement

strophe element

Tags
throws
InvalidXmlException
throws
InvalidArgumentException
throws
DomainException
Return values
Strophe

parsed object

parseVerse()

Parses a verse.

private parseVerse(SimpleXMLElement $sxml) : Verse
Parameters
$sxml : SimpleXMLElement

verse element

Tags
throws
InvalidXmlException
throws
InvalidArgumentException
throws
DomainException
Return values
Verse

parsed object

Search results