Total Complexity | 5 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | final class TypeValidatingPayloadSerializer implements PayloadSerializer |
||
8 | { |
||
9 | private $serializer; |
||
10 | private $eventClassName; |
||
11 | |||
12 | public function __construct( |
||
18 | } |
||
19 | |||
20 | public function serializePayload(object $event): array |
||
21 | { |
||
22 | if ( ! $event instanceof $this->eventClassName) { |
||
23 | throw new \InvalidArgumentException(sprintf( |
||
24 | 'Cannot serialize event that does not implement "%s".', |
||
25 | $this->eventClassName |
||
26 | )); |
||
27 | } |
||
28 | |||
29 | return $this->serializer->serializePayload($event); |
||
30 | } |
||
31 | |||
32 | public function unserializePayload(string $className, array $payload): object |
||
42 | } |
||
43 | } |
||
44 |