Skip to content

Commit

Permalink
add __serialize and __unserialize
Browse files Browse the repository at this point in the history
  • Loading branch information
grachevko committed Feb 3, 2022
1 parent 38564c1 commit 4b15294
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ final public function unserialize($serialized): void
$this->id = (int) $serialized;
}

final public function __serialize(): array
{
return ['id' => $this->toId()];
}

final public function __unserialize(array $data): void
{
$this->id = (int) $data['id'];
}

/**
* @throws InvalidArgumentException
*/
Expand Down

0 comments on commit 4b15294

Please sign in to comment.