Skip to content

Commit

Permalink
ResourceIdentifier to allow multiple meta props (fixes #99) (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
f3ath committed Dec 19, 2019
1 parent 4fb3c7a commit 5a68321
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,6 +3,7 @@ php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'

before_script:
- composer install
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.1.1] - 2019-12-19
### Fixed
- ResourceIdentifier does not allow multiple meta members (#99)

## [2.1.0] - 2019-02-25
### Fixed
- Relationship without data property (#92)
Expand All @@ -18,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- v2 initial release

[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.0...HEAD
[Unreleased]: https://github.com/json-api-php/json-api/compare/2.1.1...HEAD
[2.2.0]: https://github.com/json-api-php/json-api/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/json-api-php/json-api/compare/2.0.1...2.1.0
[2.0.1]: https://github.com/json-api-php/json-api/compare/2.0.0...2.0.1
4 changes: 2 additions & 2 deletions src/ResourceIdentifier.php
Expand Up @@ -16,7 +16,7 @@ final class ResourceIdentifier implements PrimaryData
*/
private $id;

public function __construct(string $type, string $id, Meta $meta = null)
public function __construct(string $type, string $id, Meta ...$metas)
{
if (isValidName($type) === false) {
throw new \DomainException("Invalid type value: $type");
Expand All @@ -26,7 +26,7 @@ public function __construct(string $type, string $id, Meta $meta = null)
'type' => $type,
'id' => $id,
];
if ($meta) {
foreach ($metas as $meta) {
$meta->attachTo($this->obj);
}
$this->type = $type;
Expand Down
8 changes: 6 additions & 2 deletions test/DataDocument/SingleResourceIdentifierTest.php
Expand Up @@ -36,7 +36,10 @@ public function testExtendedDocument()
"data": {
"type": "apples",
"id": "1",
"meta": {"apple_meta": "foo"}
"meta": {
"apple_meta": "foo",
"bar": [42]
}
},
"links": {
"self": "/apples/1"
Expand All @@ -51,7 +54,8 @@ public function testExtendedDocument()
new ResourceIdentifier(
'apples',
'1',
new Meta('apple_meta', 'foo')
new Meta('apple_meta', 'foo'),
new Meta('bar', [42])
),
new SelfLink('/apples/1'),
new JsonApi(),
Expand Down

0 comments on commit 5a68321

Please sign in to comment.