Skip to content

Commit 0b1b076

Browse files
authored
fix: error when attributes is null (#98)
* fix: error when attributes is null * Run Prettier --------- Co-authored-by: SychO9 <[email protected]>
1 parent 7f108dd commit 0b1b076

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Endpoint/Concerns/SavesData.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,19 @@ private function parseData(Context $context): array
6363
))->setSource(['pointer' => '/data/type']);
6464
}
6565

66-
if (isset($body['data']['attributes']) && !is_array($body['data']['attributes'])) {
66+
if (
67+
array_key_exists('attributes', $body['data']) &&
68+
!is_array($body['data']['attributes'])
69+
) {
6770
throw (new BadRequestException('data.attributes must be an object'))->setSource([
6871
'pointer' => '/data/attributes',
6972
]);
7073
}
7174

72-
if (isset($body['data']['relationships']) && !is_array($body['data']['relationships'])) {
75+
if (
76+
array_key_exists('relationships', $body['data']) &&
77+
!is_array($body['data']['relationships'])
78+
) {
7379
throw (new BadRequestException('data.relationships must be an object'))->setSource([
7480
'pointer' => '/data/relationships',
7581
]);

0 commit comments

Comments
 (0)