From 09e7d98099f416609ef724c8c484c45fcc56b831 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Fri, 5 Apr 2024 18:42:39 +0200 Subject: [PATCH] Change `getLanguage` to `getLaguages` element can be repeated in MODS document --- src/Mods/ModsReader.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Mods/ModsReader.php b/src/Mods/ModsReader.php index c86577b..e27d7c0 100644 --- a/src/Mods/ModsReader.php +++ b/src/Mods/ModsReader.php @@ -191,22 +191,26 @@ public function getIdentifiers(string $query = ''): array } /** - * Get + * Get the array of the 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; } /**