| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | namespace NxSys\Library\Clients\Brex\API\Team\Normalizer; |
| 12: | |
| 13: | use NxSys\Library\Clients\Brex\API\Team\Runtime\Normalizer\CheckArray; |
| 14: | use NxSys\Library\Clients\Brex\API\Team\Runtime\Normalizer\ValidatorTrait; |
| 15: | use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface; |
| 16: | use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait; |
| 17: | use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; |
| 18: | use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; |
| 19: | use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; |
| 20: | use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
| 21: | |
| 22: | class JaneObjectNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface |
| 23: | { |
| 24: | use DenormalizerAwareTrait; |
| 25: | use NormalizerAwareTrait; |
| 26: | use CheckArray; |
| 27: | use ValidatorTrait; |
| 28: | protected $normalizers = ['NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\Address' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\AddressNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\Card' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CardNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CardSpendControls' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CardSpendControlsNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CardMailingAddress' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CardMailingAddressNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CardAttributePreferences' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CardAttributePreferencesNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CardExpiration' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CardExpirationNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CardNumberResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CardNumberResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CompanyResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CompanyResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CreateCardRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CreateCardRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CreateCardRequestSpendControls' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CreateCardRequestSpendControlsNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CreateCardRequestMailingAddress' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CreateCardRequestMailingAddressNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CreateCardRequestCardAttributePreferences' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CreateCardRequestCardAttributePreferencesNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CreateDepartmentRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CreateDepartmentRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CreateLocationRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CreateLocationRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\CreateUserRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\CreateUserRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\DepartmentResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\DepartmentResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\LocationResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\LocationResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\LockCardRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\LockCardRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\Money' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\MoneyNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\PageCard' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\PageCardNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\PageDepartmentResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\PageDepartmentResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\PageLocationResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\PageLocationResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\PageUserResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\PageUserResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\SecureEmailForCardDetailsRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\SecureEmailForCardDetailsRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\SetUserLimitRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\SetUserLimitRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\SetUserLimitRequestMonthlyLimit' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\SetUserLimitRequestMonthlyLimitNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\SpendControl' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\SpendControlNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\SpendControlRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\SpendControlRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\SpendControlUpdateRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\SpendControlUpdateRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\SpendControlUpdateRequestSpendLimit' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\SpendControlUpdateRequestSpendLimitNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\TerminateCardRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\TerminateCardRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UpdateCardRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UpdateCardRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UpdateCardRequestSpendControls' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UpdateCardRequestSpendControlsNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UpdateUserRequest' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UpdateUserRequestNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UserLimitResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UserLimitResponseNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UserLimitResponseMonthlyLimit' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UserLimitResponseMonthlyLimitNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UserLimitResponseMonthlyAvailable' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UserLimitResponseMonthlyAvailableNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UserOwner' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UserOwnerNormalizer', 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Model\\UserResponse' => 'NxSys\\Library\\Clients\\Brex\\API\\Team\\Normalizer\\UserResponseNormalizer', '\\Jane\\Component\\JsonSchemaRuntime\\Reference' => '\\NxSys\\Library\\Clients\\Brex\\API\\Team\\Runtime\\Normalizer\\ReferenceNormalizer']; |
| 29: | protected $normalizersCache = []; |
| 30: | |
| 31: | public function supportsDenormalization($data, $type, $format = null): bool |
| 32: | { |
| 33: | return array_key_exists($type, $this->normalizers); |
| 34: | } |
| 35: | |
| 36: | public function supportsNormalization($data, $format = null): bool |
| 37: | { |
| 38: | return is_object($data) && array_key_exists(get_class($data), $this->normalizers); |
| 39: | } |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public function normalize($object, $format = null, array $context = []) |
| 45: | { |
| 46: | $normalizerClass = $this->normalizers[get_class($object)]; |
| 47: | $normalizer = $this->getNormalizer($normalizerClass); |
| 48: | |
| 49: | return $normalizer->normalize($object, $format, $context); |
| 50: | } |
| 51: | |
| 52: | |
| 53: | |
| 54: | |
| 55: | public function denormalize($data, $class, $format = null, array $context = []) |
| 56: | { |
| 57: | $denormalizerClass = $this->normalizers[$class]; |
| 58: | $denormalizer = $this->getNormalizer($denormalizerClass); |
| 59: | |
| 60: | return $denormalizer->denormalize($data, $class, $format, $context); |
| 61: | } |
| 62: | |
| 63: | private function getNormalizer(string $normalizerClass) |
| 64: | { |
| 65: | return $this->normalizersCache[$normalizerClass] ?? $this->initNormalizer($normalizerClass); |
| 66: | } |
| 67: | |
| 68: | private function initNormalizer(string $normalizerClass) |
| 69: | { |
| 70: | $normalizer = new $normalizerClass(); |
| 71: | $normalizer->setNormalizer($this->normalizer); |
| 72: | $normalizer->setDenormalizer($this->denormalizer); |
| 73: | $this->normalizersCache[$normalizerClass] = $normalizer; |
| 74: | |
| 75: | return $normalizer; |
| 76: | } |
| 77: | } |
| 78: | |