hetzner-dns-api/generated/Normalizer/ZonesFileValidatePostResponse200Normalizer.php

81 lines
No EOL
3.5 KiB
PHP

<?php
namespace DigiComp\HetznerDnsApi\Normalizer;
use Jane\Component\JsonSchemaRuntime\Reference;
use DigiComp\HetznerDnsApi\Runtime\Normalizer\CheckArray;
use Symfony\Component\Serializer\Exception\InvalidArgumentException;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class ZonesFileValidatePostResponse200Normalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use DenormalizerAwareTrait;
use NormalizerAwareTrait;
use CheckArray;
public function supportsDenormalization($data, $type, $format = null) : bool
{
return $type === 'DigiComp\\HetznerDnsApi\\Model\\ZonesFileValidatePostResponse200';
}
public function supportsNormalization($data, $format = null) : bool
{
return is_object($data) && get_class($data) === 'DigiComp\\HetznerDnsApi\\Model\\ZonesFileValidatePostResponse200';
}
/**
* @return mixed
*/
public function denormalize($data, $class, $format = null, array $context = array())
{
if (isset($data['$ref'])) {
return new Reference($data['$ref'], $context['document-origin']);
}
if (isset($data['$recursiveRef'])) {
return new Reference($data['$recursiveRef'], $context['document-origin']);
}
$object = new \DigiComp\HetznerDnsApi\Model\ZonesFileValidatePostResponse200();
if (\array_key_exists('parsed_records', $data) && \is_int($data['parsed_records'])) {
$data['parsed_records'] = (double) $data['parsed_records'];
}
if (null === $data || false === \is_array($data)) {
return $object;
}
if (\array_key_exists('parsed_records', $data) && $data['parsed_records'] !== null) {
$object->setParsedRecords($data['parsed_records']);
}
elseif (\array_key_exists('parsed_records', $data) && $data['parsed_records'] === null) {
$object->setParsedRecords(null);
}
if (\array_key_exists('valid_records', $data) && $data['valid_records'] !== null) {
$values = array();
foreach ($data['valid_records'] as $value) {
$values[] = $this->denormalizer->denormalize($value, 'DigiComp\\HetznerDnsApi\\Model\\RecordResponse', 'json', $context);
}
$object->setValidRecords($values);
}
elseif (\array_key_exists('valid_records', $data) && $data['valid_records'] === null) {
$object->setValidRecords(null);
}
return $object;
}
/**
* @return array|string|int|float|bool|\ArrayObject|null
*/
public function normalize($object, $format = null, array $context = array())
{
$data = array();
if (null !== $object->getParsedRecords()) {
$data['parsed_records'] = $object->getParsedRecords();
}
if (null !== $object->getValidRecords()) {
$values = array();
foreach ($object->getValidRecords() as $value) {
$values[] = $this->normalizer->normalize($value, 'json', $context);
}
$data['valid_records'] = $values;
}
return $data;
}
}