diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml
new file mode 100644
index 0000000..e202431
--- /dev/null
+++ b/.github/workflows/phpunit.yml
@@ -0,0 +1,27 @@
+name: PHPUnit
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+ build-test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+
+ - uses: php-actions/composer@v6
+
+ - name: Tests
+ uses: php-actions/phpunit@v3
+ env:
+ TEST_NAME: Scarlett
+ with:
+ bootstrap: vendor/autoload.php
+ configuration: phpunit.xml
+ args: --coverage-text
+ version: 9
+ php_version: "7.4"
diff --git a/composer.json b/composer.json
index 6f673a1..99c5e7a 100644
--- a/composer.json
+++ b/composer.json
@@ -10,7 +10,7 @@
"php": ">=7.4"
},
"require-dev": {
- "phpunit/phpunit": "~7.5"
+ "phpunit/phpunit": "~9.6"
},
"autoload": {
"psr-4": {
diff --git a/phpunit.xml b/phpunit.xml
index cc01c81..577ca64 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -3,7 +3,6 @@
./tests/Mods/
- ./tests/Mods/Context
diff --git a/src/Mods/Attribute/Common/Linking/XlinkHrefAttribute.php b/src/Mods/Attribute/Common/Linking/XlinkHrefAttribute.php
index 0947ef4..551fca0 100644
--- a/src/Mods/Attribute/Common/Linking/XlinkHrefAttribute.php
+++ b/src/Mods/Attribute/Common/Linking/XlinkHrefAttribute.php
@@ -24,6 +24,6 @@ trait XlinkHrefAttribute
*/
public function getXlinkHref(): string
{
- return $this->getStringAttribute('xlinkHref');
+ return $this->getStringAttribute('xlink:href');
}
}
diff --git a/src/Mods/Element/Location.php b/src/Mods/Element/Location.php
index 6f948c1..0059185 100644
--- a/src/Mods/Element/Location.php
+++ b/src/Mods/Element/Location.php
@@ -21,9 +21,11 @@
use Slub\Mods\Element\Specific\Location\HoldingSimple;
use Slub\Mods\Element\Specific\Location\PhysicalLocation;
use Slub\Mods\Element\Specific\Location\Url;
+use Slub\Mods\Element\Xml\Element;
/**
* Location MODS metadata element class for the 'php-mods-reader' library.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html
*
* @access public
*/
@@ -31,36 +33,6 @@ class Location extends BaseElement
{
use LanguageAttribute, IdAttribute, AltRepGroupAttribute, DisplayLabelAttribute;
- /**
- * @access private
- * @var PhysicalLocation
- */
- private PhysicalLocation $physicalLocation;
-
- /**
- * @access private
- * @var LanguageElement
- */
- private LanguageElement $shelfLocator;
-
- /**
- * @access private
- * @var Url
- */
- private Url $url;
-
- /**
- * @access private
- * @var HoldingSimple
- */
- private HoldingSimple $holdingSimple;
-
- /**
- * @access private
- * @var string
- */
- private string $holdingExternal;
-
/**
* This extracts the essential MODS metadata from XML
*
@@ -76,62 +48,108 @@ public function __construct(\SimpleXMLElement $xml)
}
/**
- * Get the value of physicalLocation
+ * Get the array of the elements.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#physicallocation
*
* @access public
*
- * @return PhysicalLocation
+ * @param string $query The XPath query for metadata search
+ *
+ * @return PhysicalLocation[]
*/
- public function getPhysicalLocation(): PhysicalLocation
+ public function getPhysicalLocations(string $query = ''): array
{
- return $this->physicalLocation;
+ $physicalLocations = [];
+ $xpath = './mods:physicalLocation' . $query;
+ $element = new Element($this->xml, $xpath);
+ if ($element->exists()) {
+ foreach ($element->getValues() as $value) {
+ $physicalLocations[] = new PhysicalLocation($value);
+ }
+ }
+ return $physicalLocations;
}
/**
- * Get the value of shelfLocator
+ * Get the value of the element.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#shelfLocator
*
* @access public
*
- * @return LanguageElement
+ * @param string $query The XPath query for metadata search
+ *
+ * @return ?LanguageElement
*/
- public function getShelfLocator(): LanguageElement
+ public function getShelfLocator(string $query = ''): ?LanguageElement
{
- return $this->shelfLocator;
+ $xpath = './mods:shelfLocator' . $query;
+ $element = new Element($this->xml, $xpath);
+ if ($element->exists()) {
+ return new LanguageElement($element->getValues()[0]);
+ }
+ return null;
}
/**
- * Get the value of url
+ * Get the the array of the elements.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#url
*
* @access public
*
- * @return Url
+ * @param string $query The XPath query for metadata search
+ *
+ * @return Url[]
*/
- public function getUrl(): Url
+ public function getUrls(string $query = ''): array
{
- return $this->url;
+ $urls = [];
+ $xpath = './mods:url' . $query;
+ $element = new Element($this->xml, $xpath);
+ if ($element->exists()) {
+ foreach ($element->getValues() as $value) {
+ $urls[] = new Url($value);
+ }
+ }
+ return $urls;
}
/**
- * Get the value of holdingSimple
+ * Get the value of the element.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#holdingsimple
*
* @access public
*
- * @return HoldingSimple
+ * @param string $query The XPath query for metadata search
+ *
+ * @return ?HoldingSimple
*/
- public function getHoldingSimple(): HoldingSimple
+ public function getHoldingSimple(string $query = ''): ?HoldingSimple
{
- return $this->holdingSimple;
+ $xpath = './mods:holdingSimple' . $query;
+ $element = new Element($this->xml, $xpath);
+ if ($element->exists()) {
+ return new HoldingSimple($element->getValues()[0]);
+ }
+ return null;
}
/**
- * Get the value of holdingExternal
+ * Get the value of the element.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#holdingexternal
*
* @access public
*
+ * @param string $query The XPath query for metadata search
+ *
* @return string
*/
- public function getHoldingExternal(): string
+ public function getHoldingExternal(string $query = ''): string
{
- return $this->holdingExternal;
+ $xpath = './mods:holdingExternal' . $query;
+ $element = new Element($this->xml, $xpath);
+ if ($element->exists()) {
+ return $element->getValues()[0]->asXML();
+ }
+ return '';
}
}
diff --git a/src/Mods/Element/Specific/Location/HoldingSimple.php b/src/Mods/Element/Specific/Location/HoldingSimple.php
index 3c525f7..4eae5f3 100644
--- a/src/Mods/Element/Specific/Location/HoldingSimple.php
+++ b/src/Mods/Element/Specific/Location/HoldingSimple.php
@@ -14,21 +14,17 @@
use Slub\Mods\Element\Common\BaseElement;
use Slub\Mods\Element\Specific\Location\HoldingSimple\CopyInformation;
+use Slub\Mods\Element\Xml\Element;
/**
* HoldingSimple MODS metadata element class for the 'php-mods-reader' library.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#holdingsimple
*
* @access public
*/
class HoldingSimple extends BaseElement
{
- /**
- * @access private
- * @var CopyInformation
- */
- private CopyInformation $copyInformation;
-
/**
* This extracts the essential MODS metadata from XML
*
@@ -44,14 +40,22 @@ public function __construct(\SimpleXMLElement $xml)
}
/**
- * Get the value of copyInformation
+ * Get the value of the element.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#copyinformation
*
* @access public
*
- * @return CopyInformation
+ * @param string $query The XPath query for metadata search
+ *
+ * @return ?CopyInformation
*/
- public function getCopyInformation(): CopyInformation
+ public function getCopyInformation(string $query = ''): ?CopyInformation
{
- return $this->copyInformation;
+ $xpath = './mods:copyInformation' . $query;
+ $element = new Element($this->xml, $xpath);
+ if ($element->exists()) {
+ return new CopyInformation($element->getValues()[0]);
+ }
+ return null;
}
}
diff --git a/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php b/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php
index 96dc5f7..8838fd9 100644
--- a/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php
+++ b/src/Mods/Element/Specific/Location/HoldingSimple/CopyInformation.php
@@ -18,57 +18,17 @@
use Slub\Mods\Element\Specific\Location\HoldingSimple\CopyInformation\EnumerationAndChronology;
use Slub\Mods\Element\Specific\Location\HoldingSimple\CopyInformation\ItemIdentifier;
use Slub\Mods\Element\Specific\PhysicalDescription\Form;
+use Slub\Mods\Element\Xml\Element;
/**
* HoldingSimple MODS metadata element class for the 'php-mods-reader' library.
+ * @see https://www.loc.gov/standards/mods/userguide/location.html#copyinformation
*
* @access public
*/
class CopyInformation extends BaseElement
{
- /**
- * @access private
- * @var Form
- */
- private Form $form;
-
- /**
- * @access private
- * @var LanguageElement
- */
- private LanguageElement $subLocation;
-
- /**
- * @access private
- * @var LanguageElement
- */
- private LanguageElement $shelfLocator;
-
- /**
- * @access private
- * @var string
- */
- private string $electronicLocator;
-
- /**
- * @access private
- * @var Note
- */
- private Note $note;
-
- /**
- * @access private
- * @var EnumerationAndChronology
- */
- private EnumerationAndChronology $enumerationAndChronology;
-
- /**
- * @access private
- * @var ItemIdentifier
- */
- private ItemIdentifier $itemIdentifier;
-
/**
* This extracts the essential MODS metadata from XML
*
@@ -84,43 +44,71 @@ public function __construct(\SimpleXMLElement $xml)
}
/**
- * Get the value of form
+ * Get the value of the