You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've got an array with objects. Is it possible to create a data class from an array with objects and transform them with something as fromObject() same as fromArray()?
I've tried the following functions, but no luck yet
fromObject
fromStdClass
fromStdObject
I've got something like the following code
class TestData extends Data
{
public function __construct(
public readonly string $value
) {
}
public static function fromObject(object $data): self
{
return new self(
value: $data->value
);
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all,
I've got an array with objects. Is it possible to create a data class from an array with objects and transform them with something as fromObject() same as fromArray()?
I've tried the following functions, but no luck yet
I've got something like the following code
Thanks in advance for any help!!
Beta Was this translation helpful? Give feedback.
All reactions