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