EntityInterface
A plain domain object that round-trips through persistence via {@see self::toArray()} / {@see self::fromArray()} — no base class, no attributes, no ORM coupling; any final class can implement it, the way the `example-agent-ready-blog`'s `Post` does. Conventionally the array returned by `toArray()` carries the identity under the key `'id'`, mirroring {@see self::id()} — {@see FileRepository} and {@see InMemoryRepository} rely on that key when assigning a fresh id to an entity saved without one.
EntityInterface::id()
abstract public function id(): string|int|nullThis entity's identity, or `null` when it has never been saved — an id is assigned the first time it is passed to {@see RepositoryInterface::save()}.
EntityInterface::toArray()
abstract public function toArray(): arrayProjects this entity into a plain array suitable for JSON encoding or any other serialization.
EntityInterface::fromArray()
abstract public static function fromArray(array $row): staticReconstructs an entity from the array shape produced by {@see self::toArray()}.
Parameters
| Name | Type | Description |
|---|---|---|
| $row | array<string, mixed> |