1: <?php
2:
3: declare(strict_types=1);
4:
5: /*
6: * This file has been auto generated by Jane,
7: *
8: * Do no edit it directly.
9: */
10:
11: namespace NxSys\Library\Clients\Brex\API\Transactions\Normalizer;
12:
13: use Jane\Component\JsonSchemaRuntime\Reference;
14: use NxSys\Library\Clients\Brex\API\Transactions\Runtime\Normalizer\CheckArray;
15: use NxSys\Library\Clients\Brex\API\Transactions\Runtime\Normalizer\ValidatorTrait;
16: use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
17: use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
18: use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
19: use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
20: use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
21: use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
22:
23: class PageCashTransactionNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
24: {
25: use DenormalizerAwareTrait;
26: use NormalizerAwareTrait;
27: use CheckArray;
28: use ValidatorTrait;
29:
30: public function supportsDenormalization($data, $type, $format = null): bool
31: {
32: return $type === 'NxSys\\Library\\Clients\\Brex\\API\\Transactions\\Model\\PageCashTransaction';
33: }
34:
35: public function supportsNormalization($data, $format = null): bool
36: {
37: return is_object($data) && get_class($data) === 'NxSys\\Library\\Clients\\Brex\\API\\Transactions\\Model\\PageCashTransaction';
38: }
39:
40: /**
41: * @return mixed
42: */
43: public function denormalize($data, $class, $format = null, array $context = [])
44: {
45: if (isset($data['$ref'])) {
46: return new Reference($data['$ref'], $context['document-origin']);
47: }
48: if (isset($data['$recursiveRef'])) {
49: return new Reference($data['$recursiveRef'], $context['document-origin']);
50: }
51: $object = new \NxSys\Library\Clients\Brex\API\Transactions\Model\PageCashTransaction();
52: if (null === $data || false === \is_array($data)) {
53: return $object;
54: }
55: if (\array_key_exists('next_cursor', $data) && $data['next_cursor'] !== null) {
56: $object->setNextCursor($data['next_cursor']);
57: unset($data['next_cursor']);
58: } elseif (\array_key_exists('next_cursor', $data) && $data['next_cursor'] === null) {
59: $object->setNextCursor(null);
60: }
61: if (\array_key_exists('items', $data)) {
62: $values = [];
63: foreach ($data['items'] as $value) {
64: $values[] = $this->denormalizer->denormalize($value, 'NxSys\\Library\\Clients\\Brex\\API\\Transactions\\Model\\CashTransaction', 'json', $context);
65: }
66: $object->setItems($values);
67: unset($data['items']);
68: }
69: foreach ($data as $key => $value_1) {
70: if (preg_match('/.*/', (string) $key)) {
71: $object[$key] = $value_1;
72: }
73: }
74:
75: return $object;
76: }
77:
78: /**
79: * @return array|string|int|float|bool|\ArrayObject|null
80: */
81: public function normalize($object, $format = null, array $context = [])
82: {
83: $data = [];
84: if ($object->isInitialized('nextCursor') && null !== $object->getNextCursor()) {
85: $data['next_cursor'] = $object->getNextCursor();
86: }
87: $values = [];
88: foreach ($object->getItems() as $value) {
89: $values[] = $this->normalizer->normalize($value, 'json', $context);
90: }
91: $data['items'] = $values;
92: foreach ($object as $key => $value_1) {
93: if (preg_match('/.*/', (string) $key)) {
94: $data[$key] = $value_1;
95: }
96: }
97:
98: return $data;
99: }
100: }
101: