Skip to content

Commit

Permalink
fix: ISSUE-12 - now will set property of the model dynamically withou…
Browse files Browse the repository at this point in the history
…t context of the model class
  • Loading branch information
mgcostaParedes committed Jun 1, 2021
1 parent 3c615dc commit 11110c8
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/Spanner/Traits/ModelAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ public function getAttributes(): array

public function setRawAttributes(array $attributes): void
{
$reflect = new ReflectionObject($this);
$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
foreach ($attributes as $key => $attribute) {
$exists = array_filter($props, function ($prop) use ($key) {
return $prop->name == $key && $prop->class == get_called_class();
});
if (!empty($exists)) {
$this->{$key} = $attribute;
}
$this->{$key} = $attribute;
}
}
}

0 comments on commit 11110c8

Please sign in to comment.