<?php

namespace Hydrators;

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

/**
 * THIS CLASS WAS GENERATED BY THE DOCTRINE ODM. DO NOT EDIT THIS FILE.
 */
class OfficeBrainBundleActivityBundleDocumentSearchLogHydrator implements HydratorInterface
{
    private $dm;
    private $unitOfWork;
    private $class;

    public function __construct(DocumentManager $dm, UnitOfWork $uow, ClassMetadata $class)
    {
        $this->dm = $dm;
        $this->unitOfWork = $uow;
        $this->class = $class;
    }

    public function hydrate($document, $data, array $hints = array())
    {
        $hydratedData = array();

        /** @Field(type="id") */
        if (isset($data['_id']) || (! empty($this->class->fieldMappings['id']['nullable']) && array_key_exists('_id', $data))) {
            $value = $data['_id'];
            if ($value !== null) {
                $typeIdentifier = $this->class->fieldMappings['id']['type'];
                $return = $value instanceof \MongoId ? (string) $value : $value;
            } else {
                $return = null;
            }
            $this->class->reflFields['id']->setValue($document, $return);
            $hydratedData['id'] = $return;
        }

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

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

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

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

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

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

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

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

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

        /** @Field(type="date") */
        if (isset($data['createdAt'])) {
            $value = $data['createdAt'];
            if ($value === null) { $return = null; } else { $return = \Doctrine\ODM\MongoDB\Types\DateType::getDateTime($value); }
            $this->class->reflFields['createdAt']->setValue($document, clone $return);
            $hydratedData['createdAt'] = $return;
        }

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

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