diff --git a/src/Mods/Element/Common/BaseElement.php b/src/Mods/Element/Common/BaseElement.php index c20b795..bf741a8 100644 --- a/src/Mods/Element/Common/BaseElement.php +++ b/src/Mods/Element/Common/BaseElement.php @@ -109,10 +109,8 @@ protected function getAuthorityLanguageElements(string $xpath): array { $elements = []; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $elements[] = new AuthorityLanguageElement($value); - } + foreach ($element->getValues() as $value) { + $elements[] = new AuthorityLanguageElement($value); } return $elements; } @@ -130,10 +128,8 @@ protected function getDateElements(string $xpath): array { $elements = []; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $elements[] = new DateElement($value); - } + foreach ($element->getValues() as $value) { + $elements[] = new DateElement($value); } return $elements; } @@ -169,10 +165,8 @@ protected function getLanguageElements(string $xpath): array { $elements = []; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $elements[] = new LanguageElement($value); - } + foreach ($element->getValues() as $value) { + $elements[] = new LanguageElement($value); } return $elements; } diff --git a/src/Mods/Element/Language.php b/src/Mods/Element/Language.php index dff3f23..aaa323b 100644 --- a/src/Mods/Element/Language.php +++ b/src/Mods/Element/Language.php @@ -74,10 +74,8 @@ public function getLanguageTerms(string $query = ''): array $languageTerms = []; $xpath = './mods:languageTerm' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $languageTerms[] = new LanguageTerm($value); - } + foreach ($element->getValues() as $value) { + $languageTerms[] = new LanguageTerm($value); } return $languageTerms; } @@ -97,10 +95,8 @@ public function getScriptTerms(string $query = ''): array $scriptTerms = []; $xpath = './mods:scriptTerm' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $scriptTerms[] = new ScriptTerm($value); - } + foreach ($element->getValues() as $value) { + $scriptTerms[] = new ScriptTerm($value); } return $scriptTerms; } diff --git a/src/Mods/Element/Location.php b/src/Mods/Element/Location.php index 0059185..b8d3f05 100644 --- a/src/Mods/Element/Location.php +++ b/src/Mods/Element/Location.php @@ -62,10 +62,8 @@ public function getPhysicalLocations(string $query = ''): array $physicalLocations = []; $xpath = './mods:physicalLocation' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $physicalLocations[] = new PhysicalLocation($value); - } + foreach ($element->getValues() as $value) { + $physicalLocations[] = new PhysicalLocation($value); } return $physicalLocations; } @@ -105,10 +103,8 @@ public function getUrls(string $query = ''): array $urls = []; $xpath = './mods:url' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $urls[] = new Url($value); - } + foreach ($element->getValues() as $value) { + $urls[] = new Url($value); } return $urls; } diff --git a/src/Mods/Element/Name.php b/src/Mods/Element/Name.php index 098656a..1139ce0 100644 --- a/src/Mods/Element/Name.php +++ b/src/Mods/Element/Name.php @@ -77,10 +77,8 @@ public function getAlternativeNames(string $query = ''): array $alternativeNames = []; $xpath = './mods:alternativeName' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $alternativeNames[] = new AlternativeName($value); - } + foreach ($element->getValues() as $value) { + $alternativeNames[] = new AlternativeName($value); } return $alternativeNames; } diff --git a/src/Mods/Element/OriginInfo.php b/src/Mods/Element/OriginInfo.php index 0ea781f..4086a1a 100644 --- a/src/Mods/Element/OriginInfo.php +++ b/src/Mods/Element/OriginInfo.php @@ -92,10 +92,8 @@ public function getPlaces(string $query = ''): array $places = []; $xpath = './mods:place' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $places[] = new Place($value); - } + foreach ($element->getValues() as $value) { + $places[] = new Place($value); } return $places; } @@ -115,10 +113,8 @@ public function getAgents(string $query = ''): array $agents = []; $xpath = './mods:agent' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $agents[] = new Agent($value); - } + foreach ($element->getValues() as $value) { + $agents[] = new Agent($value); } return $agents; } @@ -228,10 +224,8 @@ public function getOtherDates(string $query = ''): array $otherDates = []; $xpath = './mods:dateOther' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $otherDates[] = new DateOther($value); - } + foreach ($element->getValues() as $value) { + $otherDates[] = new DateOther($value); } return $otherDates; } @@ -251,10 +245,8 @@ public function getDisplayDates(string $query = ''): array $displayDates = []; $xpath = './mods:displayDate' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $displayDates[] = new DisplayDate($value); - } + foreach ($element->getValues() as $value) { + $displayDates[] = new DisplayDate($value); } return $displayDates; } @@ -274,10 +266,8 @@ public function getEditions(string $query = ''): array $editions = []; $xpath = './mods:edition' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $editions[] = new Edition($value); - } + foreach ($element->getValues() as $value) { + $editions[] = new Edition($value); } return $editions; } @@ -297,10 +287,8 @@ public function getIssuances(string $query = ''): array $issuances = []; $xpath = './mods:issuance' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $issuances[] = new Issuance($value); - } + foreach ($element->getValues() as $value) { + $issuances[] = new Issuance($value); } return $issuances; } @@ -320,10 +308,8 @@ public function getFrequencies(string $query = ''): array $frequencies = []; $xpath = './mods:frequency' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $frequencies[] = new Frequency($value); - } + foreach ($element->getValues() as $value) { + $frequencies[] = new Frequency($value); } return $frequencies; } diff --git a/src/Mods/Element/Part.php b/src/Mods/Element/Part.php index f88fdd8..4f1a98b 100644 --- a/src/Mods/Element/Part.php +++ b/src/Mods/Element/Part.php @@ -88,10 +88,8 @@ public function getDetails(string $query = ''): array $details = []; $xpath = './mods:detail' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $details[] = new Detail($value); - } + foreach ($element->getValues() as $value) { + $details[] = new Detail($value); } return $details; } @@ -111,10 +109,8 @@ public function getExtents(string $query = ''): array $extents = []; $xpath = './mods:extent' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $extents[] = new Extent($value); - } + foreach ($element->getValues() as $value) { + $extents[] = new Extent($value); } return $extents; } @@ -149,10 +145,8 @@ public function getTexts(string $query = ''): array $texts = []; $xpath = './mods:text' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $texts[] = new Text($value); - } + foreach ($element->getValues() as $value) { + $texts[] = new Text($value); } return $texts; } diff --git a/src/Mods/Element/PhysicalDescription.php b/src/Mods/Element/PhysicalDescription.php index c0942b8..ffed1b6 100644 --- a/src/Mods/Element/PhysicalDescription.php +++ b/src/Mods/Element/PhysicalDescription.php @@ -63,10 +63,8 @@ public function getForms(string $query = ''): array $forms = []; $xpath = './mods:form' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $forms[] = new Form($value); - } + foreach ($element->getValues() as $value) { + $forms[] = new Form($value); } return $forms; } @@ -86,10 +84,8 @@ public function getReformattingQualities(string $query = ''): array $reformattingQualities = []; $xpath = './mods:reformattingQuality' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $reformattingQualities[] = $value; - } + foreach ($element->getValues() as $value) { + $reformattingQualities[] = $value; } return $reformattingQualities; } @@ -123,10 +119,8 @@ public function getExtents(string $query = ''): array $forms = []; $xpath = './mods:extent' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $forms[] = new Extent($value); - } + foreach ($element->getValues() as $value) { + $forms[] = new Extent($value); } return $forms; } @@ -146,10 +140,8 @@ public function getDigitalOrigins(string $query = ''): array $digitalOrigins = []; $xpath = './mods:digitalOrigin' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $digitalOrigins[] = $value; - } + foreach ($element->getValues() as $value) { + $digitalOrigins[] = $value; } return $digitalOrigins; } @@ -169,10 +161,8 @@ public function getNotes(string $query = ''): array $notes = []; $xpath = './mods:note' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $notes[] = new Note($value); - } + foreach ($element->getValues() as $value) { + $notes[] = new Note($value); } return $notes; } diff --git a/src/Mods/Element/RecordInfo.php b/src/Mods/Element/RecordInfo.php index fdd1cb9..3944ed8 100644 --- a/src/Mods/Element/RecordInfo.php +++ b/src/Mods/Element/RecordInfo.php @@ -110,10 +110,8 @@ public function getRecordIdentifiers(string $query = ''): array $recordIdentifiers = []; $xpath = './mods:recordIdentifier' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $recordIdentifiers[] = new RecordIdentifier($value); - } + foreach ($element->getValues() as $value) { + $recordIdentifiers[] = new RecordIdentifier($value); } return $recordIdentifiers; } @@ -133,10 +131,8 @@ public function getRecordOrigins(string $query = ''): array $recordOrigins = []; $xpath = './mods:recordOrigin' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $recordOrigins[] = new LanguageElement($value); - } + foreach ($element->getValues() as $value) { + $recordOrigins[] = new LanguageElement($value); } return $recordOrigins; } @@ -156,10 +152,8 @@ public function getRecordInfoNotes(string $query = ''): array $recordInfoNotes = []; $xpath = './mods:recordInfoNote' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $recordInfoNotes[] = new RecordInfoNote($value); - } + foreach ($element->getValues() as $value) { + $recordInfoNotes[] = new RecordInfoNote($value); } return $recordInfoNotes; } @@ -179,10 +173,8 @@ public function getLanguageOfCatalogings(string $query = ''): array $languageOfCatalogings = []; $xpath = './mods:languageOfCataloging' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $languageOfCatalogings[] = new LanguageOfCataloging($value); - } + foreach ($element->getValues() as $value) { + $languageOfCatalogings[] = new LanguageOfCataloging($value); } return $languageOfCatalogings; } diff --git a/src/Mods/Element/Specific/Location/HoldingSimple.php b/src/Mods/Element/Specific/Location/HoldingSimple.php index a21bb2e..5a2a207 100644 --- a/src/Mods/Element/Specific/Location/HoldingSimple.php +++ b/src/Mods/Element/Specific/Location/HoldingSimple.php @@ -54,10 +54,8 @@ public function getCopyInformation(string $query = ''): array $copyInformation = []; $xpath = './mods:copyInformation' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $copyInformation[] = new CopyInformation($value); - } + foreach ($element->getValues() as $value) { + $copyInformation[] = new CopyInformation($value); } return $copyInformation; } diff --git a/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php b/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php index b0c1236..cb972e8 100644 --- a/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php +++ b/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php @@ -105,10 +105,8 @@ public function getElectronicLocators(): array { $electronicLocators = []; $element = new Element($this->xml, './mods:electronicLocator'); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $electronicLocators[] = $value; - } + foreach ($element->getValues() as $value) { + $electronicLocators[] = $value; } return $electronicLocators; } @@ -128,10 +126,8 @@ public function getNotes(string $query = ''): array $notes = []; $xpath = './mods:note' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $notes[] = new Note($value); - } + foreach ($element->getValues() as $value) { + $notes[] = new Note($value); } return $notes; } @@ -151,10 +147,8 @@ public function getEnumerationAndChronologies(string $query = ''): array $enumerationAndChronologies = []; $xpath = './mods:enumerationAndChronology' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $enumerationAndChronologies[] = new EnumerationAndChronology($value); - } + foreach ($element->getValues() as $value) { + $enumerationAndChronologies[] = new EnumerationAndChronology($value); } return $enumerationAndChronologies; } @@ -174,10 +168,8 @@ public function getItemIdentifiers(string $query = ''): array $itemIdentifiers = []; $xpath = './mods:itemIdentifier' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $itemIdentifiers[] = new ItemIdentifier($value); - } + foreach ($element->getValues() as $value) { + $itemIdentifiers[] = new ItemIdentifier($value); } return $itemIdentifiers; } diff --git a/src/Mods/Element/Specific/Name/BaseNameElement.php b/src/Mods/Element/Specific/Name/BaseNameElement.php index 48854a2..2fa44ed 100644 --- a/src/Mods/Element/Specific/Name/BaseNameElement.php +++ b/src/Mods/Element/Specific/Name/BaseNameElement.php @@ -53,10 +53,8 @@ public function getNameParts(string $query = ''): array $nameParts = []; $xpath = './mods:namePart' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $nameParts[] = new NamePart($value); - } + foreach ($element->getValues() as $value) { + $nameParts[] = new NamePart($value); } return $nameParts; } @@ -76,10 +74,8 @@ public function getNameIdentifiers(string $query): array $nameIdentifiers = []; $xpath = './mods:nameIdentifier' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $nameIdentifiers[] = new NameIdentifier($value); - } + foreach ($element->getValues() as $value) { + $nameIdentifiers[] = new NameIdentifier($value); } return $nameIdentifiers; } @@ -99,10 +95,8 @@ public function getDisplayForms(string $query = ''): array $displayForms = []; $xpath = './mods:displayForm' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $displayForms[] = new LanguageElement($value); - } + foreach ($element->getValues() as $value) { + $displayForms[] = new LanguageElement($value); } return $displayForms; } @@ -122,10 +116,8 @@ public function getAffiliations(string $query = ''): array $affiliations = []; $xpath = './mods:affiliation' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $affiliations[] = new AuthorityLanguageElement($value); - } + foreach ($element->getValues() as $value) { + $affiliations[] = new AuthorityLanguageElement($value); } return $affiliations; } @@ -145,10 +137,8 @@ public function getRoles(string $query = ''): array $roles = []; $xpath = './mods:role' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $roles[] = new Role($value); - } + foreach ($element->getValues() as $value) { + $roles[] = new Role($value); } return $roles; } @@ -168,10 +158,8 @@ public function getDescriptions(string $query = ''): array $descriptions = []; $xpath = './mods:description' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $descriptions[] = new LanguageElement($value); - } + foreach ($element->getValues() as $value) { + $descriptions[] = new LanguageElement($value); } return $descriptions; } diff --git a/src/Mods/Element/Specific/Name/Role.php b/src/Mods/Element/Specific/Name/Role.php index 151647f..b79bcbd 100644 --- a/src/Mods/Element/Specific/Name/Role.php +++ b/src/Mods/Element/Specific/Name/Role.php @@ -54,10 +54,8 @@ public function getRoleTerms(string $query = ''): array $roleTerms = []; $xpath = './mods:roleTerm' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $roleTerms[] = new RoleTerm($value); - } + foreach ($element->getValues() as $value) { + $roleTerms[] = new RoleTerm($value); } return $roleTerms; } diff --git a/src/Mods/Element/Specific/OriginInfo/Place.php b/src/Mods/Element/Specific/OriginInfo/Place.php index 7767724..bd0bf15 100644 --- a/src/Mods/Element/Specific/OriginInfo/Place.php +++ b/src/Mods/Element/Specific/OriginInfo/Place.php @@ -57,10 +57,8 @@ public function getPlaceTerms(string $query = ''): array $placeTerms = []; $xpath = './mods:placeTerm' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $placeTerms[] = new PlaceTerm($value); - } + foreach ($element->getValues() as $value) { + $placeTerms[] = new PlaceTerm($value); } return $placeTerms; } @@ -80,10 +78,8 @@ public function getPlaceIdentifiers(string $query = ''): array $placeIdentifiers = []; $xpath = './mods:placeIdentifier' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $placeIdentifiers[] = new BaseElement($value); - } + foreach ($element->getValues() as $value) { + $placeIdentifiers[] = new BaseElement($value); } return $placeIdentifiers; } @@ -103,10 +99,8 @@ public function getCartographics(string $query = ''): array $cartographics = []; $xpath = './mods:cartographics' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $cartographics[] = new Cartographics($value); - } + foreach ($element->getValues() as $value) { + $cartographics[] = new Cartographics($value); } return $cartographics; } diff --git a/src/Mods/Element/Specific/Subject/HierarchicalGeographic.php b/src/Mods/Element/Specific/Subject/HierarchicalGeographic.php index 3e77528..e9bfa75 100644 --- a/src/Mods/Element/Specific/Subject/HierarchicalGeographic.php +++ b/src/Mods/Element/Specific/Subject/HierarchicalGeographic.php @@ -57,10 +57,8 @@ public function getContinents(string $query = ''): array $continents = []; $xpath = './mods:continent' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $continents[] = new LevelPeriodElement($value); - } + foreach ($element->getValues() as $value) { + $continents[] = new LevelPeriodElement($value); } return $continents; } @@ -80,10 +78,8 @@ public function getCountries(string $query = ''): array $countries = []; $xpath = './mods:country' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $countries[] = new LevelPeriodElement($value); - } + foreach ($element->getValues() as $value) { + $countries[] = new LevelPeriodElement($value); } return $countries; } @@ -103,10 +99,8 @@ public function getRegions(string $query = ''): array $regions = []; $xpath = './mods:region' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $regions[] = new TypeElement($value, 'regionType'); - } + foreach ($element->getValues() as $value) { + $regions[] = new TypeElement($value, 'regionType'); } return $regions; } @@ -126,10 +120,8 @@ public function getStates(string $query = ''): array $states = []; $xpath = './mods:state' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $states[] = new TypeElement($value, 'stateType'); - } + foreach ($element->getValues() as $value) { + $states[] = new TypeElement($value, 'stateType'); } return $states; } @@ -149,10 +141,8 @@ public function getTerritories(string $query = ''): array $territories = []; $xpath = './mods:territory' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $territories[] = new LevelPeriodElement($value); - } + foreach ($element->getValues() as $value) { + $territories[] = new LevelPeriodElement($value); } return $territories; } @@ -172,10 +162,8 @@ public function getCounties(string $query = ''): array $counties = []; $xpath = './mods:county' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $counties[] = new LevelPeriodElement($value); - } + foreach ($element->getValues() as $value) { + $counties[] = new LevelPeriodElement($value); } return $counties; } @@ -195,10 +183,8 @@ public function getCities(string $query = ''): array $cities = []; $xpath = './mods:city' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { + foreach ($element->getValues() as $value) { $cities[] = new LevelPeriodElement($value); - } } return $cities; } @@ -218,10 +204,8 @@ public function getCitySections(string $query = ''): array $sections = []; $xpath = './mods:citySection' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $sections[] = new TypeElement($value, 'citySectionType'); - } + foreach ($element->getValues() as $value) { + $sections[] = new TypeElement($value, 'citySectionType'); } return $sections; } @@ -241,10 +225,8 @@ public function getIslands(string $query = ''): array $islands = []; $xpath = './mods:island' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $islands[] = new LevelPeriodElement($value); - } + foreach ($element->getValues() as $value) { + $islands[] = new LevelPeriodElement($value); } return $islands; } @@ -264,10 +246,8 @@ public function getAreas(string $query = ''): array $areas = []; $xpath = './mods:area' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $areas[] = new TypeElement($value, 'areaType'); - } + foreach ($element->getValues() as $value) { + $areas[] = new TypeElement($value, 'areaType'); } return $areas; } @@ -287,10 +267,8 @@ public function getExtraterrestrialAreas(string $query = ''): array $extraterrestrialAreas = []; $xpath = './mods:extraterrestrialArea' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $extraterrestrialAreas[] = new LevelPeriodElement($value); - } + foreach ($element->getValues() as $value) { + $extraterrestrialAreas[] = new LevelPeriodElement($value); } return $extraterrestrialAreas; } diff --git a/src/Mods/Element/Subject.php b/src/Mods/Element/Subject.php index 51b4339..f3f735a 100644 --- a/src/Mods/Element/Subject.php +++ b/src/Mods/Element/Subject.php @@ -66,10 +66,8 @@ public function getTopics(string $query = ''): array $topics = []; $xpath = './mods:topic' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $topics[] = new AuthorityLanguageElement($value); - } + foreach ($element->getValues() as $value) { + $topics[] = new AuthorityLanguageElement($value); } return $topics; } @@ -89,10 +87,8 @@ public function getGeographics(string $query = ''): array $geographics = []; $xpath = './mods:geographic' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $geographics[] = new AuthorityLanguageElement($value); - } + foreach ($element->getValues() as $value) { + $geographics[] = new AuthorityLanguageElement($value); } return $geographics; } @@ -112,10 +108,8 @@ public function getTemporals(string $query = ''): array $temporals = []; $xpath = './mods:temporal' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $temporals[] = new AuthorityDateLanguageElement($value); - } + foreach ($element->getValues() as $value) { + $temporals[] = new AuthorityDateLanguageElement($value); } return $temporals; } @@ -135,10 +129,8 @@ public function getTitleInfos(string $query = ''): array $titleInfos = []; $xpath = './mods:titleInfo' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $titleInfos[] = new TitleInfo($value); - } + foreach ($element->getValues() as $value) { + $titleInfos[] = new TitleInfo($value); } return $titleInfos; } @@ -158,10 +150,8 @@ public function getNames(string $query = ''): array $names = []; $xpath = './mods:name' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $names[] = new Name($value); - } + foreach ($element->getValues() as $value) { + $names[] = new Name($value); } return $names; } @@ -181,10 +171,8 @@ public function getGenres(string $query = ''): array $genres = []; $xpath = './mods:genre' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $genres[] = new Genre($value); - } + foreach ($element->getValues() as $value) { + $genres[] = new Genre($value); } return $genres; } @@ -204,10 +192,8 @@ public function getHierarchicalGeographics(string $query = ''): array $hierarchicalGeographics = []; $xpath = './mods:hierarchicalGeographic' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $hierarchicalGeographics[] = new HierarchicalGeographic($value); - } + foreach ($element->getValues() as $value) { + $hierarchicalGeographics[] = new HierarchicalGeographic($value); } return $hierarchicalGeographics; } @@ -227,10 +213,8 @@ public function getCartographics(string $query = ''): array $cartographics = []; $xpath = './mods:cartographics' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $cartographics[] = new Cartographics($value); - } + foreach ($element->getValues() as $value) { + $cartographics[] = new Cartographics($value); } return $cartographics; } @@ -250,10 +234,8 @@ public function getGeographicCodes(string $query = ''): array $geographicCodes = []; $xpath = './mods:geographicCode' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $geographicCodes[] = new AuthorityLanguageElement($value); - } + foreach ($element->getValues() as $value) { + $geographicCodes[] = new AuthorityLanguageElement($value); } return $geographicCodes; } @@ -273,10 +255,8 @@ public function getOccupations(string $query = ''): array $occupations = []; $xpath = './mods:occupation' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $occupations[] = new AuthorityLanguageElement($value); - } + foreach ($element->getValues() as $value) { + $occupations[] = new AuthorityLanguageElement($value); } return $occupations; } diff --git a/src/Mods/Element/TitleInfo.php b/src/Mods/Element/TitleInfo.php index 48078ac..0305199 100644 --- a/src/Mods/Element/TitleInfo.php +++ b/src/Mods/Element/TitleInfo.php @@ -161,10 +161,8 @@ public function getPartName(string $query = ''): array $partNames = []; $xpath = './mods:partName' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $partNames[] = new LanguageElement($value); - } + foreach ($element->getValues() as $value) { + $partNames[] = new LanguageElement($value); } return $partNames; } diff --git a/src/Mods/ModsReader.php b/src/Mods/ModsReader.php index 52e2bf7..2959171 100644 --- a/src/Mods/ModsReader.php +++ b/src/Mods/ModsReader.php @@ -97,10 +97,8 @@ public function getAccessConditions(string $query = ''): array $accessConditions = []; $xpath = './mods:accessCondition' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $accessConditions[] = new AccessCondition($value); - } + foreach ($element->getValues() as $value) { + $accessConditions[] = new AccessCondition($value); } return $accessConditions; } @@ -120,10 +118,8 @@ public function getClassifications(string $query = ''): array $classifications = []; $xpath = './mods:classification' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $classifications[] = new Classification($value); - } + foreach ($element->getValues() as $value) { + $classifications[] = new Classification($value); } return $classifications; } @@ -143,10 +139,8 @@ public function getExtensions(string $query = ''): array $extensions = []; $xpath = './mods:extension' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $extensions[] = new Extension($value); - } + foreach ($element->getValues() as $value) { + $extensions[] = new Extension($value); } return $extensions; } @@ -166,10 +160,8 @@ public function getGenres(string $query = ''): array $genres = []; $xpath = './mods:genre' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $genres[] = new Genre($value); - } + foreach ($element->getValues() as $value) { + $genres[] = new Genre($value); } return $genres; } @@ -189,10 +181,8 @@ public function getIdentifiers(string $query = ''): array $identifiers = []; $xpath = './mods:identifier' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $identifiers[] = new Identifier($value); - } + foreach ($element->getValues() as $value) { + $identifiers[] = new Identifier($value); } return $identifiers; } @@ -212,10 +202,8 @@ public function getLanguages(string $query = ''): array $languages = []; $xpath = './mods:language' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $languages[] = new Language($value); - } + foreach ($element->getValues() as $value) { + $languages[] = new Language($value); } return $languages; } @@ -235,10 +223,8 @@ public function getLocations(string $query = ''): array $locations = []; $xpath = './mods:location' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $locations[] = new Location($value); - } + foreach ($element->getValues() as $value) { + $locations[] = new Location($value); } return $locations; } @@ -258,10 +244,8 @@ public function getNames(string $query = ''): array $names = []; $xpath = './mods:name' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $names[] = new Name($value); - } + foreach ($element->getValues() as $value) { + $names[] = new Name($value); } return $names; } @@ -281,10 +265,8 @@ public function getNotes(string $query = ''): array $notes = []; $xpath = './mods:note' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $notes[] = new Note($value); - } + foreach ($element->getValues() as $value) { + $notes[] = new Note($value); } return $notes; } @@ -304,10 +286,8 @@ public function getOriginInfos(string $query = ''): array $originInfos = []; $xpath = './mods:originInfo' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $originInfos[] = new OriginInfo($value); - } + foreach ($element->getValues() as $value) { + $originInfos[] = new OriginInfo($value); } return $originInfos; } @@ -327,10 +307,8 @@ public function getParts(string $query = ''): array $parts = []; $xpath = './mods:part' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $parts[] = new Part($value); - } + foreach ($element->getValues() as $value) { + $parts[] = new Part($value); } return $parts; } @@ -350,10 +328,8 @@ public function getPhysicalDescriptions(string $query = ''): array $physicalDescriptions = []; $xpath = './mods:physicalDescription' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $physicalDescriptions[] = new PhysicalDescription($value); - } + foreach ($element->getValues() as $value) { + $physicalDescriptions[] = new PhysicalDescription($value); } return $physicalDescriptions; } @@ -373,10 +349,8 @@ public function getRecordInfos(string $query = ''): array $recordInfos = []; $xpath = './mods:recordInfo' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $recordInfos[] = new RecordInfo($value); - } + foreach ($element->getValues() as $value) { + $recordInfos[] = new RecordInfo($value); } return $recordInfos; } @@ -396,10 +370,8 @@ public function getRelatedItems(string $query = ''): array $relatedItems = []; $xpath = './mods:relatedItem' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $relatedItems[] = new RelatedItem($value); - } + foreach ($element->getValues() as $value) { + $relatedItems[] = new RelatedItem($value); } return $relatedItems; } @@ -419,10 +391,8 @@ public function getSubjects(string $query = ''): array $subjects = []; $xpath = './mods:subject' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $subjects[] = new Subject($value); - } + foreach ($element->getValues() as $value) { + $subjects[] = new Subject($value); } return $subjects; } @@ -442,10 +412,8 @@ public function getTableOfContents(string $query = ''): array $tableOfContents = []; $xpath = './mods:tableOfContents' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $tableOfContents[] = new TableOfContents($value); - } + foreach ($element->getValues() as $value) { + $tableOfContents[] = new TableOfContents($value); } return $tableOfContents; } @@ -465,10 +433,8 @@ public function getTargetAudience(string $query = ''): array $targetAudiences = []; $xpath = './mods:targetAudience' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $targetAudiences[] = new TargetAudience($value); - } + foreach ($element->getValues() as $value) { + $targetAudiences[] = new TargetAudience($value); } return $targetAudiences; } @@ -488,10 +454,8 @@ public function getTitleInfos(string $query = ''): array $titleInfos = []; $xpath = './mods:titleInfo' . $query; $element = new Element($this->xml, $xpath); - if ($element->exists()) { - foreach ($element->getValues() as $value) { - $titleInfos[] = new TitleInfo($value); - } + foreach ($element->getValues() as $value) { + $titleInfos[] = new TitleInfo($value); } return $titleInfos; }