diff --git a/src/Model/Reference/DataReference.php b/src/Model/Reference/DataReference.php index ed091108..e9575904 100644 --- a/src/Model/Reference/DataReference.php +++ b/src/Model/Reference/DataReference.php @@ -23,6 +23,7 @@ final class DataReference implements Reference, HasDoi private $source; private $dataId; private $assigningAuthority; + private $specificUse; private $doi; private $uri; @@ -43,6 +44,7 @@ public function __construct( string $source, string $dataId = null, Place $assigningAuthority = null, + string $specificUse = null, string $doi = null, string $uri = null ) { @@ -59,6 +61,7 @@ public function __construct( $this->source = $source; $this->dataId = $dataId; $this->assigningAuthority = $assigningAuthority; + $this->specificUse = $specificUse; $this->doi = $doi; $this->uri = $uri; } @@ -143,6 +146,14 @@ public function getAssigningAuthority() return $this->assigningAuthority; } + /** + * @return string|null + */ + public function getSpecificUse() + { + return $this->specificUse; + } + /** * @return string|null */ diff --git a/src/Serializer/Reference/DataReferenceNormalizer.php b/src/Serializer/Reference/DataReferenceNormalizer.php index 1bf2cfa8..3b0d21d7 100644 --- a/src/Serializer/Reference/DataReferenceNormalizer.php +++ b/src/Serializer/Reference/DataReferenceNormalizer.php @@ -42,6 +42,7 @@ public function denormalize($data, $class, $format = null, array $context = []) $data['dataId'] ?? null, empty($data['assigningAuthority']) ? null : $this->denormalizer->denormalize($data['assigningAuthority'], Place::class, $format, $context), + $data['specificUse'] ?? null, $data['doi'] ?? null, $data['uri'] ?? null ); @@ -111,6 +112,10 @@ public function normalize($object, $format = null, array $context = []) : array $context); } + if ($object->getSpecificUse()) { + $data['specificUse'] = $object->getSpecificUse(); + } + if ($object->getDoi()) { $data['doi'] = $object->getDoi(); } diff --git a/test/Model/Reference/DataReferenceTest.php b/test/Model/Reference/DataReferenceTest.php index f9ff0e02..7f3bfdad 100644 --- a/test/Model/Reference/DataReferenceTest.php +++ b/test/Model/Reference/DataReferenceTest.php @@ -224,7 +224,7 @@ public function it_may_have_a_doi() { $with = new DataReference('id', new Date(2000), null, [new PersonAuthor(new PersonDetails('preferred name', 'index name'))], false, [], false, [], false, 'title', - 'source', null, null, '10.1000/182'); + 'source', null, null, null, '10.1000/182'); $withOut = new DataReference('id', new Date(2000), null, [new PersonAuthor(new PersonDetails('preferred name', 'index name'))], false, [], false, [], false, 'title', 'source'); @@ -241,7 +241,7 @@ public function it_may_have_a_uri() { $with = new DataReference('id', new Date(2000), null, [new PersonAuthor(new PersonDetails('preferred name', 'index name'))], false, [], false, [], false, 'title', - 'source', null, null, null, 'http://www.example.com/'); + 'source', null, null, null, null, 'http://www.example.com/'); $withOut = new DataReference('id', new Date(2000), null, [new PersonAuthor(new PersonDetails('preferred name', 'index name'))], false, [], false, [], false, 'title', 'source'); diff --git a/test/Serializer/Reference/DataReferenceNormalizerTest.php b/test/Serializer/Reference/DataReferenceNormalizerTest.php index 1f89f00d..33015aa0 100644 --- a/test/Serializer/Reference/DataReferenceNormalizerTest.php +++ b/test/Serializer/Reference/DataReferenceNormalizerTest.php @@ -86,7 +86,7 @@ public function normalizeProvider() : array [new PersonAuthor(new PersonDetails('curator preferred name', 'curator index name'))], true, 'title', 'source', 'id', new Place(['assigning authority']), - // 'analyzed', + 'analyzed', '10.1000/182', 'http://www.example.com/'), [ @@ -132,7 +132,7 @@ public function normalizeProvider() : array 'assigning authority', ], ], - // 'specificUse' => 'analyzed', + 'specificUse' => 'analyzed', 'doi' => '10.1000/182', 'uri' => 'http://www.example.com/', ], @@ -244,6 +244,7 @@ public function denormalizeProvider() : array 'assigning authority', ], ], + 'specificUse' => 'analyzed', 'doi' => '10.1000/182', 'uri' => 'http://www.example.com/', ], @@ -252,7 +253,9 @@ public function denormalizeProvider() : array [new PersonAuthor(new PersonDetails('compiler preferred name', 'compiler index name'))], true, [new PersonAuthor(new PersonDetails('curator preferred name', 'curator index name'))], true, 'title', - 'source', 'id', new Place(['assigning authority']), '10.1000/182', + 'source', 'id', new Place(['assigning authority']), + 'analyzed', + '10.1000/182', 'http://www.example.com/'), ], 'minimum' => [