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

97 lines
3.7 KiB
PHP
Raw Permalink Normal View History

2023-01-05 12:55:52 +01:00
<?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 BaseRecordNormalizer implements DenormalizerInterface, NormalizerInterface, DenormalizerAwareInterface, NormalizerAwareInterface
{
use DenormalizerAwareTrait;
use NormalizerAwareTrait;
use CheckArray;
public function supportsDenormalization($data, $type, $format = null) : bool
{
return $type === 'DigiComp\\HetznerDnsApi\\Model\\BaseRecord';
}
public function supportsNormalization($data, $format = null) : bool
{
return is_object($data) && get_class($data) === 'DigiComp\\HetznerDnsApi\\Model\\BaseRecord';
}
/**
* @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\BaseRecord();
if (null === $data || false === \is_array($data)) {
return $object;
}
if (\array_key_exists('zone_id', $data) && $data['zone_id'] !== null) {
$object->setZoneId($data['zone_id']);
}
elseif (\array_key_exists('zone_id', $data) && $data['zone_id'] === null) {
$object->setZoneId(null);
}
if (\array_key_exists('type', $data) && $data['type'] !== null) {
$object->setType($data['type']);
}
elseif (\array_key_exists('type', $data) && $data['type'] === null) {
$object->setType(null);
}
if (\array_key_exists('name', $data) && $data['name'] !== null) {
$object->setName($data['name']);
}
elseif (\array_key_exists('name', $data) && $data['name'] === null) {
$object->setName(null);
}
if (\array_key_exists('value', $data) && $data['value'] !== null) {
$object->setValue($data['value']);
}
elseif (\array_key_exists('value', $data) && $data['value'] === null) {
$object->setValue(null);
}
if (\array_key_exists('ttl', $data) && $data['ttl'] !== null) {
$object->setTtl($data['ttl']);
}
elseif (\array_key_exists('ttl', $data) && $data['ttl'] === null) {
$object->setTtl(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->getZoneId()) {
$data['zone_id'] = $object->getZoneId();
}
if (null !== $object->getType()) {
$data['type'] = $object->getType();
}
if (null !== $object->getName()) {
$data['name'] = $object->getName();
}
if (null !== $object->getValue()) {
$data['value'] = $object->getValue();
}
if (null !== $object->getTtl()) {
$data['ttl'] = $object->getTtl();
}
return $data;
}
}