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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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