<?php

namespace Hydrators;

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\Hydrator\HydratorException;
use Doctrine\ODM\MongoDB\Hydrator\HydratorInterface;
use Doctrine\ODM\MongoDB\Query\Query;
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;

use function array_key_exists;
use function gettype;
use function is_array;

/**
 * THIS CLASS WAS GENERATED BY THE DOCTRINE ODM. DO NOT EDIT THIS FILE.
 */
class AppDocumentTransportZoneConstraintsHydrator implements HydratorInterface
{
    public function __construct(private DocumentManager $dm, private ClassMetadata $class) {}

    public function hydrate(object $document, array $data, array $hints = []): array
    {
        $hydratedData = [];

        // Field(type: "float")
        if (isset($data['minimumWeight']) || (! empty($this->class->fieldMappings['minimumWeight']['nullable']) && array_key_exists('minimumWeight', $data))) {
            $value = $data['minimumWeight'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['minimumWeight']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['minimumWeight']->setValue($document, $return);
            $hydratedData['minimumWeight'] = $return;
        }

        // Field(type: "float")
        if (isset($data['maximumWeight']) || (! empty($this->class->fieldMappings['maximumWeight']['nullable']) && array_key_exists('maximumWeight', $data))) {
            $value = $data['maximumWeight'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['maximumWeight']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['maximumWeight']->setValue($document, $return);
            $hydratedData['maximumWeight'] = $return;
        }

        // Field(type: "float")
        if (isset($data['minimumVolume']) || (! empty($this->class->fieldMappings['minimumVolume']['nullable']) && array_key_exists('minimumVolume', $data))) {
            $value = $data['minimumVolume'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['minimumVolume']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['minimumVolume']->setValue($document, $return);
            $hydratedData['minimumVolume'] = $return;
        }

        // Field(type: "float")
        if (isset($data['maximumVolume']) || (! empty($this->class->fieldMappings['maximumVolume']['nullable']) && array_key_exists('maximumVolume', $data))) {
            $value = $data['maximumVolume'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['maximumVolume']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['maximumVolume']->setValue($document, $return);
            $hydratedData['maximumVolume'] = $return;
        }

        // Field(type: "float")
        if (isset($data['maximumParcelDimension']) || (! empty($this->class->fieldMappings['maximumParcelDimension']['nullable']) && array_key_exists('maximumParcelDimension', $data))) {
            $value = $data['maximumParcelDimension'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['maximumParcelDimension']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['maximumParcelDimension']->setValue($document, $return);
            $hydratedData['maximumParcelDimension'] = $return;
        }

        // Field(type: "float")
        if (isset($data['maximumSecondDimension']) || (! empty($this->class->fieldMappings['maximumSecondDimension']['nullable']) && array_key_exists('maximumSecondDimension', $data))) {
            $value = $data['maximumSecondDimension'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['maximumSecondDimension']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['maximumSecondDimension']->setValue($document, $return);
            $hydratedData['maximumSecondDimension'] = $return;
        }

        // Field(type: "float")
        if (isset($data['maximumThirdDimension']) || (! empty($this->class->fieldMappings['maximumThirdDimension']['nullable']) && array_key_exists('maximumThirdDimension', $data))) {
            $value = $data['maximumThirdDimension'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['maximumThirdDimension']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['maximumThirdDimension']->setValue($document, $return);
            $hydratedData['maximumThirdDimension'] = $return;
        }

        // Field(type: "float")
        if (isset($data['maximumDeveloped']) || (! empty($this->class->fieldMappings['maximumDeveloped']['nullable']) && array_key_exists('maximumDeveloped', $data))) {
            $value = $data['maximumDeveloped'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['maximumDeveloped']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['maximumDeveloped']->setValue($document, $return);
            $hydratedData['maximumDeveloped'] = $return;
        }

        // Field(type: "bool")
        if (isset($data['requirePcbOneForAllParcels']) || (! empty($this->class->fieldMappings['requirePcbOneForAllParcels']['nullable']) && array_key_exists('requirePcbOneForAllParcels', $data))) {
            $value = $data['requirePcbOneForAllParcels'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['requirePcbOneForAllParcels']['type'];
                $return = (bool) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['requirePcbOneForAllParcels']->setValue($document, $return);
            $hydratedData['requirePcbOneForAllParcels'] = $return;
        }

        // Field(type: "bool")
        if (isset($data['requireAllParcelsPalletisable']) || (! empty($this->class->fieldMappings['requireAllParcelsPalletisable']['nullable']) && array_key_exists('requireAllParcelsPalletisable', $data))) {
            $value = $data['requireAllParcelsPalletisable'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['requireAllParcelsPalletisable']['type'];
                $return = (bool) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['requireAllParcelsPalletisable']->setValue($document, $return);
            $hydratedData['requireAllParcelsPalletisable'] = $return;
        }

        return $hydratedData;
    }
}