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\Payments\Normalizer;
12:
13: use Jane\Component\JsonSchemaRuntime\Reference;
14: use NxSys\Library\Clients\Brex\API\Payments\Runtime\Normalizer\CheckArray;
15: use NxSys\Library\Clients\Brex\API\Payments\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 BankAccountDetailsResponseNormalizer 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\\Payments\\Model\\BankAccountDetailsResponse';
33: }
34:
35: public function supportsNormalization($data, $format = null): bool
36: {
37: return is_object($data) && get_class($data) === 'NxSys\\Library\\Clients\\Brex\\API\\Payments\\Model\\BankAccountDetailsResponse';
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\Payments\Model\BankAccountDetailsResponse();
52: if (null === $data || false === \is_array($data)) {
53: return $object;
54: }
55: if (\array_key_exists('type', $data)) {
56: $object->setType($data['type']);
57: unset($data['type']);
58: }
59: if (\array_key_exists('routing_number', $data) && $data['routing_number'] !== null) {
60: $object->setRoutingNumber($data['routing_number']);
61: unset($data['routing_number']);
62: } elseif (\array_key_exists('routing_number', $data) && $data['routing_number'] === null) {
63: $object->setRoutingNumber(null);
64: }
65: if (\array_key_exists('account_number', $data) && $data['account_number'] !== null) {
66: $object->setAccountNumber($data['account_number']);
67: unset($data['account_number']);
68: } elseif (\array_key_exists('account_number', $data) && $data['account_number'] === null) {
69: $object->setAccountNumber(null);
70: }
71: if (\array_key_exists('description', $data) && $data['description'] !== null) {
72: $object->setDescription($data['description']);
73: unset($data['description']);
74: } elseif (\array_key_exists('description', $data) && $data['description'] === null) {
75: $object->setDescription(null);
76: }
77: if (\array_key_exists('beneficiary_bank', $data)) {
78: $object->setBeneficiaryBank($this->denormalizer->denormalize($data['beneficiary_bank'], 'NxSys\\Library\\Clients\\Brex\\API\\Payments\\Model\\BankAccountDetailsResponsebeneficiaryBank', 'json', $context));
79: unset($data['beneficiary_bank']);
80: }
81: if (\array_key_exists('fed_reference_number', $data) && $data['fed_reference_number'] !== null) {
82: $object->setFedReferenceNumber($data['fed_reference_number']);
83: unset($data['fed_reference_number']);
84: } elseif (\array_key_exists('fed_reference_number', $data) && $data['fed_reference_number'] === null) {
85: $object->setFedReferenceNumber(null);
86: }
87: if (\array_key_exists('external_memo', $data) && $data['external_memo'] !== null) {
88: $object->setExternalMemo($data['external_memo']);
89: unset($data['external_memo']);
90: } elseif (\array_key_exists('external_memo', $data) && $data['external_memo'] === null) {
91: $object->setExternalMemo(null);
92: }
93: foreach ($data as $key => $value) {
94: if (preg_match('/.*/', (string) $key)) {
95: $object[$key] = $value;
96: }
97: }
98:
99: return $object;
100: }
101:
102: /**
103: * @return array|string|int|float|bool|\ArrayObject|null
104: */
105: public function normalize($object, $format = null, array $context = [])
106: {
107: $data = [];
108: $data['type'] = $object->getType();
109: if ($object->isInitialized('routingNumber') && null !== $object->getRoutingNumber()) {
110: $data['routing_number'] = $object->getRoutingNumber();
111: }
112: if ($object->isInitialized('accountNumber') && null !== $object->getAccountNumber()) {
113: $data['account_number'] = $object->getAccountNumber();
114: }
115: if ($object->isInitialized('description') && null !== $object->getDescription()) {
116: $data['description'] = $object->getDescription();
117: }
118: if ($object->isInitialized('beneficiaryBank') && null !== $object->getBeneficiaryBank()) {
119: $data['beneficiary_bank'] = $this->normalizer->normalize($object->getBeneficiaryBank(), 'json', $context);
120: }
121: if ($object->isInitialized('fedReferenceNumber') && null !== $object->getFedReferenceNumber()) {
122: $data['fed_reference_number'] = $object->getFedReferenceNumber();
123: }
124: if ($object->isInitialized('externalMemo') && null !== $object->getExternalMemo()) {
125: $data['external_memo'] = $object->getExternalMemo();
126: }
127: foreach ($object as $key => $value) {
128: if (preg_match('/.*/', (string) $key)) {
129: $data[$key] = $value;
130: }
131: }
132:
133: return $data;
134: }
135: }
136: