diff --git a/src/Currency.php b/src/Currency.php index 733e6902..3e20cba4 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -5,6 +5,7 @@ namespace Money; use JsonSerializable; +use Serializable; use function strtoupper; @@ -15,7 +16,7 @@ * * @psalm-immutable */ -final class Currency implements JsonSerializable +final class Currency implements JsonSerializable, Serializable { /** * Currency code. @@ -66,8 +67,23 @@ public function __serialize(): array return ['code' => $this->code]; } + # TODO Correct PSALM? public function __unserialize(array $data): void { $this->code = (string) $data['code']; } + + /** + * @return array + */ + public function serialize(): array + { + return $this->__serialize(); + } + + # TODO Correct PSALM? + public function unserialize(string $data) + { + return $this->__unserialize($data); + } }