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

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

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

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

        return $hydratedData;
    }
}