| Total Complexity | 3 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 9 | class MessageMapper implements MessageMapperInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var \Jellyfish\Queue\MessageFactoryInterface |
||
| 13 | */ |
||
| 14 | protected $messageFactory; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var \Jellyfish\Serializer\SerializerInterface |
||
| 18 | */ |
||
| 19 | protected $serializer; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @param \Jellyfish\Serializer\SerializerInterface $serializer |
||
| 23 | */ |
||
| 24 | public function __construct( |
||
| 25 | SerializerInterface $serializer |
||
| 26 | ) { |
||
| 27 | $this->serializer = $serializer; |
||
| 28 | } |
||
| 29 | |||
| 30 | |||
| 31 | /** |
||
| 32 | * @param string $json |
||
| 33 | * |
||
| 34 | * @return \Jellyfish\Queue\MessageInterface |
||
| 35 | */ |
||
| 36 | public function fromJson(string $json): MessageInterface |
||
| 37 | { |
||
| 38 | /** @var \Jellyfish\Queue\MessageInterface $message */ |
||
| 39 | $message = $this->serializer->deserialize($json, Message::class, 'json'); |
||
| 40 | |||
| 41 | return $message; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param \Jellyfish\Queue\MessageInterface $message |
||
| 46 | * |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | public function toJson(MessageInterface $message): string |
||
| 52 | } |
||
| 53 | } |
||
| 54 |