Total Complexity | 6 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Coverage | 92.86% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class JsonHttpSerializer implements HttpSerializerInterface |
||
11 | { |
||
12 | /** @var EncoderInterface */ |
||
13 | protected $encoder; |
||
14 | |||
15 | /** |
||
16 | * Serializer constructor. |
||
17 | * @param EncoderInterface $encoder |
||
18 | */ |
||
19 | 2 | public function __construct(EncoderInterface $encoder) |
|
20 | { |
||
21 | 2 | $this->encoder = $encoder; |
|
22 | 2 | } |
|
23 | |||
24 | /** |
||
25 | * @param $data |
||
26 | * @return string |
||
27 | * @throws Encoder\Exception |
||
28 | */ |
||
29 | 17 | public function serialize($data): string |
|
30 | { |
||
31 | 17 | return $this->encoder->encode($data); |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * Should deserialize HTTP RAW data to array. |
||
36 | * |
||
37 | * @param string $data |
||
38 | * @return array |
||
39 | * @throws HttpBadRequestException |
||
40 | */ |
||
41 | 7 | public function deserialize(string $data): array |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return array |
||
56 | */ |
||
57 | 1 | public function getResponseHeaders(): array |
|
60 | } |
||
61 | } |
||
62 |