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

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

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

        return $hydratedData;
    }
}