Skip to content

Commit 23b57b5

Browse files
committed
fix(Item): better include data.meta
Don't need the weird getDataMeta()
1 parent 8ffe003 commit 23b57b5

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Item.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ public function hasAttributes(): bool
114114
return !empty($this->toArray());
115115
}
116116

117-
/**
118-
* @return Meta
119-
*/
120-
public function getDataMeta(): Meta
121-
{
122-
return $this->meta;
123-
}
124-
125117
/**
126118
* @return array
127119
*/
@@ -150,6 +142,9 @@ public function getRelationships(): array
150142
'type' => $relation->getIncluded()->getType(),
151143
'id' => $relation->getIncluded()->getId(),
152144
];
145+
if ($relation->getIncluded()->getMeta()) {
146+
$relationships[$name]['data']['meta'] = $relation->getIncluded()->getMeta();
147+
}
153148
}
154149
} elseif ($relation instanceof ManyRelationInterface) {
155150
$relationships[$name]['data'] = [];

tests/Parsers/ItemParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ public function itParsesMetaInData()
657657

658658
$item = $parser->parse($this->getJsonApiItemMock('master', '1'));
659659

660-
$dataMeta = $item->getRelation('childwithdatameta')->getIncluded()->getDataMeta();
660+
$dataMeta = $item->getRelation('childwithdatameta')->getIncluded()->getMeta();
661661
static::assertInstanceOf(Meta::class, $dataMeta);
662662

663663
$image = $dataMeta->imageDerivatives->links->header->href;

0 commit comments

Comments
 (0)