Skip to content

Commit 1ead0e7

Browse files
committed
Bugfix: Better decision if ResourceIdentifier or ResourceItem
1 parent d55173e commit 1ead0e7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Document.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,12 @@ protected function parseData($data)
205205
throw new ValidationException('Data value has to be null or an object, "' . gettype($data) . '" given.');
206206
}
207207

208-
$object_vars = get_object_vars($data);
208+
$object_keys = array_keys(get_object_vars($data));
209+
sort($object_keys);
209210

210211
// the properties must be type and id or
211212
// the 3 properties must be type, id and meta
212-
if ( count($object_vars) === 2 or (count($object_vars) === 3 and property_exists($data, 'meta')) )
213+
if ( $object_keys === ['id', 'type'] or $object_keys === ['id', 'meta', 'type'] )
213214
{
214215
$resource = $this->manager->getFactory()->make(
215216
'ResourceIdentifier',

0 commit comments

Comments
 (0)