<?php is_object(mixed $value): bool
<?php if ($this->isEnum($key) && !is_object($value)) { return $cast::tryFrom($value); }
<?php foreach ($attributes as $key => $value) { $set = 'set'.str_replace('_', '', ucwords($key, '_')); if (is_object($value) || !method_exists($this, $set)) { $this->attributes[$key] = $value; continue; }
<?php $this->$set( is_array($value) && isset($value[0]) ? array_map(fn($v) => is_object($v) ? $v : new $cast($v), $value) : new $cast($value) ); }
<?php $array[$key] = $value->toArray(); } elseif (is_array($value)) { $array[$key] = array_map(fn($v) => $v instanceof Type ? $v->toArray() : $v, $value); } elseif ($this->isEnum($key) && is_object($value)) { $array[$key] = $value->value; } else { $array[$key] = $value;