Total Complexity | 3 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
15 | class SetChatMenuButtonNormalizer implements NormalizerInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var NormalizerInterface |
||
19 | */ |
||
20 | private $objectNormalizer; |
||
21 | |||
22 | /** |
||
23 | * JsonSerializableNormalizer constructor. |
||
24 | */ |
||
25 | public function __construct(NormalizerInterface $objectNormalizer) |
||
26 | { |
||
27 | $this->objectNormalizer = $objectNormalizer; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param SetChatMenuButtonMethod $topic |
||
32 | * @param null $format |
||
|
|||
33 | * |
||
34 | * @throws ExceptionInterface |
||
35 | * |
||
36 | * @return array|bool|false|float|int|string |
||
37 | */ |
||
38 | public function normalize($topic, $format = null, array $context = []) |
||
39 | { |
||
40 | $serializer = new Serializer([ |
||
41 | new JsonSerializableNormalizer($this->objectNormalizer), |
||
42 | $this->objectNormalizer, |
||
43 | ]); |
||
44 | |||
45 | $topic->menuButton = \json_encode($serializer->normalize($topic->menuButton, null, ['skip_null_values' => true])); |
||
46 | |||
47 | return $serializer->normalize($topic, null, ['skip_null_values' => true]); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param mixed $data |
||
52 | * @param null $format |
||
53 | */ |
||
54 | public function supportsNormalization($data, $format = null): bool |
||
57 | } |
||
58 | } |
||
59 |