Skip to content

Commit 052a189

Browse files
committed
Refactor Attributes and RelationshipColletion
1 parent a5cda9f commit 052a189

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

src/V1/Attributes.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ protected function parse(mixed $object): void
3535
throw new ValidationException('These properties are not allowed in attributes: `type`, `id`, `relationships`, `links`');
3636
}
3737

38-
$object_vars = get_object_vars($object);
39-
40-
if (count($object_vars) === 0) {
41-
return;
42-
}
43-
44-
foreach ($object_vars as $name => $value) {
38+
foreach (get_object_vars($object) as $name => $value) {
4539
$this->set($name, $value);
4640
}
4741
}

src/V1/RelationshipCollection.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,7 @@ protected function parse(mixed $object): void
3535
throw new ValidationException('These properties are not allowed in attributes: `type`, `id`');
3636
}
3737

38-
$object_vars = get_object_vars($object);
39-
40-
if (count($object_vars) === 0) {
41-
return;
42-
}
43-
44-
foreach ($object_vars as $name => $value) {
38+
foreach (get_object_vars($object) as $name => $value) {
4539
if ($this->getParent()->has('attributes.' . $name)) {
4640
throw new ValidationException('"' . $name . '" property cannot be set because it exists already in parents Resource object.');
4741
}

0 commit comments

Comments
 (0)