<?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 AppDocumentEverestRegionHydrator implements HydratorInterface
{
    public function __construct(private DocumentManager $dm, private ClassMetadata $class) {}

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

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

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

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

        return $hydratedData;
    }
}