Total Complexity | 5 |
Total Lines | 24 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
7 | final class TypeValidatingPayloadSerializer implements PayloadSerializer |
||
8 | { |
||
9 | public function __construct( |
||
13 | } |
||
14 | |||
15 | public function serializePayload(object $event): array |
||
16 | { |
||
17 | if ( ! $event instanceof $this->eventClassName) { |
||
18 | throw new \InvalidArgumentException(sprintf('Cannot serialize event that does not implement "%s".', $this->eventClassName)); |
||
19 | 5 | } |
|
20 | |||
21 | return $this->serializer->serializePayload($event); |
||
22 | } |
||
23 | 5 | ||
24 | 5 | public function unserializePayload(string $className, array $payload): object |
|
31 | } |
||
32 | } |
||
33 |