1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Gember\SerializerSymfony; |
||
6 | |||
7 | use Gember\EventSourcing\Util\Serialization\Serializer\Serializer; |
||
8 | use Symfony\Component\Serializer\Encoder\JsonEncoder; |
||
9 | use Symfony\Component\Serializer\SerializerInterface; |
||
10 | use Override; |
||
11 | |||
12 | final readonly class SymfonySerializer implements Serializer |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
13 | { |
||
14 | 2 | public function __construct( |
|
15 | private SerializerInterface $serializer, |
||
16 | 2 | ) {} |
|
17 | |||
18 | 1 | #[Override] |
|
19 | public function serialize(object $object): string |
||
20 | { |
||
21 | 1 | return $this->serializer->serialize($object, JsonEncoder::FORMAT); |
|
22 | } |
||
23 | |||
24 | 1 | #[Override] |
|
25 | public function deserialize(string $payload, string $className): object |
||
26 | { |
||
27 | /** @var object */ |
||
28 | 1 | return $this->serializer->deserialize($payload, $className, JsonEncoder::FORMAT); |
|
29 | } |
||
30 | } |
||
31 |