<?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 AppDocumentLogisticsDetailsHydrator 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['logisticDeliveryCost']) || (! empty($this->class->fieldMappings['logisticDeliveryCost']['nullable']) && array_key_exists('logisticDeliveryCost', $data))) {
            $value = $data['logisticDeliveryCost'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['logisticDeliveryCost']['type'];
                $return = (float) $value;
            } else {
                $return = null;
            }
            $this->class->propertyAccessors['logisticDeliveryCost']->setValue($document, $return);
            $hydratedData['logisticDeliveryCost'] = $return;
        }

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

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

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

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

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

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

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

        return $hydratedData;
    }
}