Skip to content

Commit

Permalink
Change getLanguage to getLaguages
Browse files Browse the repository at this point in the history
<language> element can be repeated in MODS document
  • Loading branch information
beatrycze-volk committed Apr 5, 2024
1 parent b6d11d3 commit 09e7d98
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Mods/ModsReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,26 @@ public function getIdentifiers(string $query = ''): array
}

/**
* Get
* Get the array of the <language> elements.
* @see https://www.loc.gov/standards/mods/userguide/language.html
*
* @access public
*
* @param string $query The XPath query for metadata search
*
* @return ?Language
* @return Language[]
*/
public function getLanguage(string $query = ''): ?Language
public function getLanguages(string $query = ''): array
{
$languages = [];
$xpath = './mods:language' . $query;
$element = new Element($this->xml, $xpath);
if ($element->exists()) {
return new Language($element->getValues()[0]);
foreach ($element->getValues() as $value) {
$languages[] = new Language($value);
}
}
return null;
return $languages;
}

/**
Expand Down

0 comments on commit 09e7d98

Please sign in to comment.