Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor Attributes and RelationshipColletion
  • Loading branch information
Art4 committed Jul 19, 2024
commit 052a189d94e7f99f99f5291c9beec580ed349d27
8 changes: 1 addition & 7 deletions src/V1/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ protected function parse(mixed $object): void
throw new ValidationException('These properties are not allowed in attributes: `type`, `id`, `relationships`, `links`');
}

$object_vars = get_object_vars($object);

if (count($object_vars) === 0) {
return;
}

foreach ($object_vars as $name => $value) {
foreach (get_object_vars($object) as $name => $value) {
$this->set($name, $value);
}
}
Expand Down
8 changes: 1 addition & 7 deletions src/V1/RelationshipCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,7 @@ protected function parse(mixed $object): void
throw new ValidationException('These properties are not allowed in attributes: `type`, `id`');
}

$object_vars = get_object_vars($object);

if (count($object_vars) === 0) {
return;
}

foreach ($object_vars as $name => $value) {
foreach (get_object_vars($object) as $name => $value) {
if ($this->getParent()->has('attributes.' . $name)) {
throw new ValidationException('"' . $name . '" property cannot be set because it exists already in parents Resource object.');
}
Expand Down