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

61 lines
No EOL
2.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 MetaNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use DenormalizerAwareTrait;
use NormalizerAwareTrait;
use CheckArray;
public function supportsDenormalization($data, $type, $format = null) : bool
{
return $type === 'DigiComp\\HetznerDnsApi\\Model\\Meta';
}
public function supportsNormalization($data, $format = null) : bool
{
return is_object($data) && get_class($data) === 'DigiComp\\HetznerDnsApi\\Model\\Meta';
}
/**
* @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\Meta();
if (null === $data || false === \is_array($data)) {
return $object;
}
if (\array_key_exists('pagination', $data) && $data['pagination'] !== null) {
$object->setPagination($this->denormalizer->denormalize($data['pagination'], 'DigiComp\\HetznerDnsApi\\Model\\Pagination', 'json', $context));
}
elseif (\array_key_exists('pagination', $data) && $data['pagination'] === null) {
$object->setPagination(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->getPagination()) {
$data['pagination'] = $this->normalizer->normalize($object->getPagination(), 'json', $context);
}
return $data;
}
}