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\Team\Normalizer;
12:
13: use Jane\Component\JsonSchemaRuntime\Reference;
14: use NxSys\Library\Clients\Brex\API\Team\Runtime\Normalizer\CheckArray;
15: use NxSys\Library\Clients\Brex\API\Team\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 UserResponseNormalizer 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\\Team\\Model\\UserResponse';
33: }
34:
35: public function supportsNormalization($data, $format = null): bool
36: {
37: return is_object($data) && get_class($data) === 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UserResponse';
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\Team\Model\UserResponse();
52: if (null === $data || false === \is_array($data)) {
53: return $object;
54: }
55: if (\array_key_exists('id', $data)) {
56: $object->setId($data['id']);
57: unset($data['id']);
58: }
59: if (\array_key_exists('first_name', $data)) {
60: $object->setFirstName($data['first_name']);
61: unset($data['first_name']);
62: }
63: if (\array_key_exists('last_name', $data)) {
64: $object->setLastName($data['last_name']);
65: unset($data['last_name']);
66: }
67: if (\array_key_exists('email', $data)) {
68: $object->setEmail($data['email']);
69: unset($data['email']);
70: }
71: if (\array_key_exists('status', $data)) {
72: $object->setStatus($data['status']);
73: unset($data['status']);
74: }
75: if (\array_key_exists('manager_id', $data) && $data['manager_id'] !== null) {
76: $object->setManagerId($data['manager_id']);
77: unset($data['manager_id']);
78: } elseif (\array_key_exists('manager_id', $data) && $data['manager_id'] === null) {
79: $object->setManagerId(null);
80: }
81: if (\array_key_exists('department_id', $data) && $data['department_id'] !== null) {
82: $object->setDepartmentId($data['department_id']);
83: unset($data['department_id']);
84: } elseif (\array_key_exists('department_id', $data) && $data['department_id'] === null) {
85: $object->setDepartmentId(null);
86: }
87: if (\array_key_exists('location_id', $data) && $data['location_id'] !== null) {
88: $object->setLocationId($data['location_id']);
89: unset($data['location_id']);
90: } elseif (\array_key_exists('location_id', $data) && $data['location_id'] === null) {
91: $object->setLocationId(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['id'] = $object->getId();
109: $data['first_name'] = $object->getFirstName();
110: $data['last_name'] = $object->getLastName();
111: $data['email'] = $object->getEmail();
112: if ($object->isInitialized('status') && null !== $object->getStatus()) {
113: $data['status'] = $object->getStatus();
114: }
115: if ($object->isInitialized('managerId') && null !== $object->getManagerId()) {
116: $data['manager_id'] = $object->getManagerId();
117: }
118: if ($object->isInitialized('departmentId') && null !== $object->getDepartmentId()) {
119: $data['department_id'] = $object->getDepartmentId();
120: }
121: if ($object->isInitialized('locationId') && null !== $object->getLocationId()) {
122: $data['location_id'] = $object->getLocationId();
123: }
124: foreach ($object as $key => $value) {
125: if (preg_match('/.*/', (string) $key)) {
126: $data[$key] = $value;
127: }
128: }
129:
130: return $data;
131: }
132: }
133: