| Total Complexity | 5 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 11 | final class Serializer implements SerializerInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var NormalizerInterface |
||
| 15 | */ |
||
| 16 | private $normalizer; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var EncoderInterface |
||
| 20 | */ |
||
| 21 | private $encoder; |
||
| 22 | |||
| 23 | public function __construct(NormalizerInterface $normalizer, EncoderInterface $encoder) |
||
| 24 | { |
||
| 25 | $this->normalizer = $normalizer; |
||
| 26 | $this->encoder = $encoder; |
||
| 27 | 4 | } |
|
| 28 | |||
| 29 | 4 | /** |
|
| 30 | 4 | * @param object $object |
|
| 31 | 4 | * @param string $path |
|
| 32 | */ |
||
| 33 | public function serialize( |
||
| 34 | $object, |
||
| 35 | string $contentType, |
||
| 36 | NormalizerContextInterface $context = null, |
||
| 37 | $path = '' |
||
| 38 | ): string { |
||
| 39 | return $this->encoder->encode($this->normalizer->normalize($object, $context, $path), $contentType); |
||
| 40 | } |
||
| 41 | 1 | ||
| 42 | /** |
||
| 43 | * @param object $object |
||
| 44 | * |
||
| 45 | * @throws SerializerLogicException |
||
| 46 | */ |
||
| 47 | 1 | public function normalize($object, NormalizerContextInterface $context = null, string $path = ''): array |
|
| 48 | { |
||
| 49 | return $this->normalizer->normalize($object, $context, $path); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string[] |
||
| 54 | */ |
||
| 55 | public function getContentTypes(): array |
||
| 58 | } |
||
| 59 | 1 | ||
| 60 | /** |
||
| 61 | 1 | * @throws SerializerLogicException |
|
| 62 | */ |
||
| 63 | public function encode(array $data, string $contentType): string |
||
| 66 | } |
||
| 67 | } |
||
| 68 |