Skip to content

Commit 5a68321

Browse files
authoredDec 19, 2019
ResourceIdentifier to allow multiple meta props (fixes #99) (#100)
1 parent 4fb3c7a commit 5a68321

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed
 

‎.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ php:
33
- '7.1'
44
- '7.2'
55
- '7.3'
6+
- '7.4'
67

78
before_script:
89
- composer install

‎CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased]
88

9+
## [2.1.1] - 2019-12-19
10+
### Fixed
11+
- ResourceIdentifier does not allow multiple meta members (#99)
12+
913
## [2.1.0] - 2019-02-25
1014
### Fixed
1115
- Relationship without data property (#92)
@@ -18,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1822
### Added
1923
- v2 initial release
2024

21-
[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.0...HEAD
25+
[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.1...HEAD
26+
[2.2.0]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1
2227
[2.1.0]: https://github.com/json-api-php/json-api/compare/2.0.1...2.1.0
2328
[2.0.1]: https://github.com/json-api-php/json-api/compare/2.0.0...2.0.1

‎src/ResourceIdentifier.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class ResourceIdentifier implements PrimaryData
1616
*/
1717
private $id;
1818

19-
public function __construct(string $type, string $id, Meta $meta = null)
19+
public function __construct(string $type, string $id, Meta ...$metas)
2020
{
2121
if (isValidName($type) === false) {
2222
throw new \DomainException("Invalid type value: $type");
@@ -26,7 +26,7 @@ public function __construct(string $type, string $id, Meta $meta = null)
2626
'type' => $type,
2727
'id' => $id,
2828
];
29-
if ($meta) {
29+
foreach ($metas as $meta) {
3030
$meta->attachTo($this->obj);
3131
}
3232
$this->type = $type;

‎test/DataDocument/SingleResourceIdentifierTest.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ public function testExtendedDocument()
3636
"data": {
3737
"type": "apples",
3838
"id": "1",
39-
"meta": {"apple_meta": "foo"}
39+
"meta": {
40+
"apple_meta": "foo",
41+
"bar": [42]
42+
}
4043
},
4144
"links": {
4245
"self": "/apples/1"
@@ -51,7 +54,8 @@ public function testExtendedDocument()
5154
new ResourceIdentifier(
5255
'apples',
5356
'1',
54-
new Meta('apple_meta', 'foo')
57+
new Meta('apple_meta', 'foo'),
58+
new Meta('bar', [42])
5559
),
5660
new SelfLink('/apples/1'),
5761
new JsonApi(),

0 commit comments

Comments
 (0)
Failed to load comments.