Skip to content

Commit

Permalink
Improved Arrayable
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyTapok-bit committed Mar 1, 2024
1 parent 7e61600 commit 913ab5b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Support/Arrayable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use ReflectionClass;
use ReflectionProperty;
use TgWebValid\Make\Make;

abstract class Arrayable
{
Expand All @@ -26,10 +25,9 @@ public function toArray(?object $object = null): array
foreach ($properties as $property) {
$name = $property->getName();
$value = $object->$name ?? null;
$result[$name] = match(true) {
$value instanceof Make => $this->toArray($value),
default => $value
};
$result[$name] = $value instanceof self
? $this->toArray($value)
: $value;
}

return $result;
Expand Down

0 comments on commit 913ab5b

Please sign in to comment.