Skip to content

Commit 4b15294

Browse files
committed
add __serialize and __unserialize
1 parent 38564c1 commit 4b15294

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Enum.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,16 @@ final public function unserialize($serialized): void
229229
$this->id = (int) $serialized;
230230
}
231231

232+
final public function __serialize(): array
233+
{
234+
return ['id' => $this->toId()];
235+
}
236+
237+
final public function __unserialize(array $data): void
238+
{
239+
$this->id = (int) $data['id'];
240+
}
241+
232242
/**
233243
* @throws InvalidArgumentException
234244
*/

0 commit comments

Comments
 (0)