|
16 | 16 | use Jane\Component\JsonSchemaRuntime\Reference; |
17 | 17 | use JoliCode\Slack\Api\Runtime\Normalizer\CheckArray; |
18 | 18 | use JoliCode\Slack\Api\Runtime\Normalizer\ValidatorTrait; |
19 | | -use Symfony\Component\HttpKernel\Kernel; |
20 | 19 | use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; |
21 | 20 | use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; |
22 | 21 | use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; |
23 | 22 | use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; |
24 | 23 | use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; |
25 | 24 | use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
26 | 25 |
|
27 | | -if (!class_exists(Kernel::class) || (Kernel::MAJOR_VERSION >= 7 || Kernel::MAJOR_VERSION === 6 && Kernel::MINOR_VERSION === 4)) { |
28 | | - class AdminAppsApprovePostResponse200Normalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface |
| 26 | +class AdminAppsApprovePostResponse200Normalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface |
| 27 | +{ |
| 28 | + use CheckArray; |
| 29 | + use DenormalizerAwareTrait; |
| 30 | + use NormalizerAwareTrait; |
| 31 | + use ValidatorTrait; |
| 32 | + |
| 33 | + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool |
29 | 34 | { |
30 | | - use CheckArray; |
31 | | - use DenormalizerAwareTrait; |
32 | | - use NormalizerAwareTrait; |
33 | | - use ValidatorTrait; |
| 35 | + return \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class === $type; |
| 36 | + } |
34 | 37 |
|
35 | | - public function supportsDenormalization(mixed $data, string $type, ?string $format = null, array $context = []): bool |
36 | | - { |
37 | | - return \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class === $type; |
38 | | - } |
| 38 | + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool |
| 39 | + { |
| 40 | + return \is_object($data) && \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class === \get_class($data); |
| 41 | + } |
39 | 42 |
|
40 | | - public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool |
41 | | - { |
42 | | - return \is_object($data) && \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class === \get_class($data); |
| 43 | + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed |
| 44 | + { |
| 45 | + if (isset($data['$ref'])) { |
| 46 | + return new Reference($data['$ref'], $context['document-origin']); |
43 | 47 | } |
44 | | - |
45 | | - public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed |
46 | | - { |
47 | | - if (isset($data['$ref'])) { |
48 | | - return new Reference($data['$ref'], $context['document-origin']); |
49 | | - } |
50 | | - if (isset($data['$recursiveRef'])) { |
51 | | - return new Reference($data['$recursiveRef'], $context['document-origin']); |
52 | | - } |
53 | | - $object = new \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200(); |
54 | | - if (null === $data || false === \is_array($data)) { |
55 | | - return $object; |
56 | | - } |
57 | | - if (\array_key_exists('ok', $data) && null !== $data['ok']) { |
58 | | - $object->setOk($data['ok']); |
59 | | - unset($data['ok']); |
60 | | - } elseif (\array_key_exists('ok', $data) && null === $data['ok']) { |
61 | | - $object->setOk(null); |
62 | | - } |
63 | | - foreach ($data as $key => $value) { |
64 | | - if (preg_match('/.*/', (string) $key)) { |
65 | | - $object[$key] = $value; |
66 | | - } |
67 | | - } |
68 | | - |
| 48 | + if (isset($data['$recursiveRef'])) { |
| 49 | + return new Reference($data['$recursiveRef'], $context['document-origin']); |
| 50 | + } |
| 51 | + $object = new \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200(); |
| 52 | + if (\array_key_exists('ok', $data) && \is_int($data['ok'])) { |
| 53 | + $data['ok'] = (bool) $data['ok']; |
| 54 | + } |
| 55 | + if (null === $data || false === \is_array($data)) { |
69 | 56 | return $object; |
70 | 57 | } |
71 | | - |
72 | | - public function normalize(mixed $object, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null |
73 | | - { |
74 | | - $data = []; |
75 | | - $data['ok'] = $object->getOk(); |
76 | | - foreach ($object as $key => $value) { |
77 | | - if (preg_match('/.*/', (string) $key)) { |
78 | | - $data[$key] = $value; |
79 | | - } |
| 58 | + if (\array_key_exists('ok', $data) && null !== $data['ok']) { |
| 59 | + $object->setOk($data['ok']); |
| 60 | + unset($data['ok']); |
| 61 | + } elseif (\array_key_exists('ok', $data) && null === $data['ok']) { |
| 62 | + $object->setOk(null); |
| 63 | + } |
| 64 | + foreach ($data as $key => $value) { |
| 65 | + if (preg_match('/.*/', (string) $key)) { |
| 66 | + $object[$key] = $value; |
80 | 67 | } |
81 | | - |
82 | | - return $data; |
83 | 68 | } |
84 | 69 |
|
85 | | - public function getSupportedTypes(?string $format = null): array |
86 | | - { |
87 | | - return [\JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class => false]; |
88 | | - } |
| 70 | + return $object; |
89 | 71 | } |
90 | | -} else { |
91 | | - class AdminAppsApprovePostResponse200Normalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface |
92 | | - { |
93 | | - use CheckArray; |
94 | | - use DenormalizerAwareTrait; |
95 | | - use NormalizerAwareTrait; |
96 | | - use ValidatorTrait; |
97 | | - |
98 | | - public function supportsDenormalization($data, $type, ?string $format = null, array $context = []): bool |
99 | | - { |
100 | | - return \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class === $type; |
101 | | - } |
102 | | - |
103 | | - public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool |
104 | | - { |
105 | | - return \is_object($data) && \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class === \get_class($data); |
106 | | - } |
107 | 72 |
|
108 | | - public function denormalize($data, $type, $format = null, array $context = []) |
109 | | - { |
110 | | - if (isset($data['$ref'])) { |
111 | | - return new Reference($data['$ref'], $context['document-origin']); |
112 | | - } |
113 | | - if (isset($data['$recursiveRef'])) { |
114 | | - return new Reference($data['$recursiveRef'], $context['document-origin']); |
115 | | - } |
116 | | - $object = new \JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200(); |
117 | | - if (null === $data || false === \is_array($data)) { |
118 | | - return $object; |
119 | | - } |
120 | | - if (\array_key_exists('ok', $data) && null !== $data['ok']) { |
121 | | - $object->setOk($data['ok']); |
122 | | - unset($data['ok']); |
123 | | - } elseif (\array_key_exists('ok', $data) && null === $data['ok']) { |
124 | | - $object->setOk(null); |
125 | | - } |
126 | | - foreach ($data as $key => $value) { |
127 | | - if (preg_match('/.*/', (string) $key)) { |
128 | | - $object[$key] = $value; |
129 | | - } |
| 73 | + public function normalize(mixed $data, ?string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null |
| 74 | + { |
| 75 | + $dataArray = []; |
| 76 | + $dataArray['ok'] = $data->getOk(); |
| 77 | + foreach ($data as $key => $value) { |
| 78 | + if (preg_match('/.*/', (string) $key)) { |
| 79 | + $dataArray[$key] = $value; |
130 | 80 | } |
131 | | - |
132 | | - return $object; |
133 | 81 | } |
134 | 82 |
|
135 | | - /** |
136 | | - * @return array|string|int|float|bool|\ArrayObject|null |
137 | | - */ |
138 | | - public function normalize($object, $format = null, array $context = []) |
139 | | - { |
140 | | - $data = []; |
141 | | - $data['ok'] = $object->getOk(); |
142 | | - foreach ($object as $key => $value) { |
143 | | - if (preg_match('/.*/', (string) $key)) { |
144 | | - $data[$key] = $value; |
145 | | - } |
146 | | - } |
147 | | - |
148 | | - return $data; |
149 | | - } |
| 83 | + return $dataArray; |
| 84 | + } |
150 | 85 |
|
151 | | - public function getSupportedTypes(?string $format = null): array |
152 | | - { |
153 | | - return [\JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class => false]; |
154 | | - } |
| 86 | + public function getSupportedTypes(?string $format = null): array |
| 87 | + { |
| 88 | + return [\JoliCode\Slack\Api\Model\AdminAppsApprovePostResponse200::class => false]; |
155 | 89 | } |
156 | 90 | } |
0 commit comments