Hydrate $object with the provided $data.

Naming strategy: Converts properties to camelCase (e.g. fooBarBaz).

@param array $data
@param object $object
@return object
174152
public function hydrate(array $data, $object)
    {
        foreach ($data as $name => $value) {
            $property = StringUtil::camel($name);
            if (property_exists($object, $property)) {
                $object->{$property} = $value;
            }
        }

        return $object;
    }
1160491
public static function setDataOptionAttributes($data, $object)
    {
        if(is_array($data) && count($data) > 0)
        {
            $keys = array_keys($data);

            $response = '';
            foreach($keys as $key)
            {
                $response .= ' data-' . $key . '="' . $object->{$data[$key]} . '"';
            }

            return $response;
        }

        return null;
    }
773120
public function hydrate(array $data, $object)
    {
        if (!$object instanceof TicketEntry) {
            throw new \InvalidArgumentException('$object must be an instance of TicketEntry');
        }

        return parent::hydrate($data, $object);
    }
1243006
protected function hydrateProperties($entity, $data)
    {
        if (isset($data['attributes']) && is_array($data['attributes'])) {
            $entity = parent::hydrateProperties($entity, $data['attributes']);
        }

        return $entity;
    }
1195533
public function hydrate(array $data, $object)
    {
        $array = [];
        $hydrator = new AnnotationHydrator();

        foreach ($data as $value) {
            $clonedObject = clone $object;
            $array[] = $hydrator->hydrate($value, $clonedObject);
        }

        return $array;
    }
1321723
public function hydrate(array $data, $object)
    {
        parent::hydrate($data, $object);

        foreach ($this->getFreeValuesKeys() as $key) {
            if (isset($data[$key])) {
                $object->set($key, $data[$key]);
            }
        }

        return $object;
    }
130838
private function hydrateClassObject($obj, $data)
    {
        // loop through the class object and hydrate it
        foreach ($data as $property => $value) {
            $this->hydrate($obj, $property, $value);
        }

        return $obj;
    }
867722
public function hydrate(&$object, $data, $soft = false, $maxReferenceDepth = 10)
    {
        $strategy = $this->documentManager->getOptions()['hydratorStrategy'] ?? self::STRAT_SETTERS;
        $reflectionClass = new \ReflectionClass($this->classMetadata->getName());
        if ($data instanceof \MongoDB\Model\BSONArray || $data instanceof \MongoDB\Model\BSONDocument) {
            $data = (array) $data;
        }

        if (!is_array($data)) {
            throw new \Exception('$data must be an array');
        }
        $properties = $this->classMetadata->getPropertiesInfos();

        foreach ($properties as $name => $infos) {
            $setter = 'set' . ucfirst($name);
            if (!$reflectionClass->hasMethod($setter) || $strategy === self::STRAT_ATTRIBUTES) {
                $prop = new \ReflectionProperty($this->classMetadata->getName(), $name);
                $prop->setAccessible(true);
            } else {
                $prop = null;
            }

            if (null !== ($field = $infos->getField())) {
                if (!$soft && !array_key_exists($field, $data)) {
                    $this->setValue($object, null, $setter, $prop);
                } elseif (array_key_exists($field, $data)) {
                    if (!$soft && $data[$field] === null) {
                        continue;
                    }
                    if ((($data[$field] instanceof \MongoDB\Model\BSONDocument) || is_array($data[$field])) && $infos->getEmbedded() && null !== ($class = $infos->getEmbeddedClass())) {
                        if ($infos->isDiscriminable()) {
                            if (null !== ($discrimatorField = $infos->getDiscriminatorField())
                                && null !== ($discrimatorMap = $infos->getDiscriminatorMap())) {
                                $discriminatorValue = isset($data[$field][$discrimatorField]) ? $data[$field][$discrimatorField] : null;
                                if (isset($discriminatorValue)) {
                                    $class = isset($discrimatorMap[$discriminatorValue]) ? $discrimatorMap[$discriminatorValue] : $class;
                                }
                            } else {
                                $discriminatorValue = isset($data[$field]) ? $data[$field] : null;
                                $method = $infos->getDiscriminatorMethod();
                                $class = $object->$method($discriminatorValue);
                            }
                        }
                        if (!class_exists($class)) {
                            $class = $this->classMetadata->getNamespace() . "\\" . $class;
                        }
                        if ($data[$field] instanceof $class) {
                            $embedded = $data[$field];
                        } else {
                            $embedded = new $class();
                            $this->getHydrator($class)->hydrate($embedded, $data[$field]);
                        }
                        $data[$field] = $embedded;
                    } elseif ((($data[$field] instanceof \MongoDB\Model\BSONArray) || ($data[$field] instanceof \MongoDB\Model\BSONDocument) || is_array($data[$field])) && $infos->getMultiEmbedded() && null !== ($class = $infos->getEmbeddedClass())) {
                        $array = [];
                        $originalClass = $class;
                        foreach ($data[$field] as $key => $value) {
                            if ($infos->isDiscriminable()) {
                                if (null !== ($discrimatorField = $infos->getDiscriminatorField())
                                    && null !== ($discrimatorMap = $infos->getDiscriminatorMap())) {
                                    $discriminatorValue = isset($data[$field][$key][$discrimatorField]) ? $data[$field][$key][$discrimatorField] : null;
                                    if (isset($discriminatorValue)) {
                                        $class = isset($discrimatorMap[$discriminatorValue]) ? $discrimatorMap[$discriminatorValue] : $originalClass;
                                    }
                                    if (!class_exists($class)) {
                                        $class = $this->classMetadata->getNamespace() . "\\" . $class;
                                    }
                                } else {
                                    //call_s
                                }
                            }
                            if (!class_exists($class)) {
                                $class = $this->classMetadata->getNamespace() . "\\" . $originalClass;
                            }
                            if ($value === null) {
                                continue;
                            }

                            if ($value instanceof $class) {
                                $embedded = $value;
                            } else {
                                $embedded = new $class();
                                $this->getHydrator($class)->hydrate($embedded, $value);
                            }
                            $array[$key] = $embedded;
                        }
                        $data[$field] = $array;
                    } elseif (null !== ($refInfos = $infos->getReferenceInfo()) && !$refInfos->getIsMultiple() && $maxReferenceDepth > 0) {
                        $repository = $this->repositoryFactory->getRepository($this->documentManager, $refInfos->getDocument(), $refInfos->getCollection());

                        $objectDatas = $repository->getCollection()->findOne(["_id" => $data[$field]]);
                        $referedObject = null;

                        if (isset($objectDatas)) {
                            $class = $refInfos->getDocument();

                            if (!class_exists($class)) {
                                $class = $this->classMetadata->getNamespace() . "\\" . $class;
                            }

                            $referedObject = new $class();

                            $hydrator = $repository->getHydrator();
                            $hydrator->hydrate($referedObject, $objectDatas, $soft, $maxReferenceDepth - 1);
                        }
                        $data[$field] = $referedObject;
                    } elseif (null !== ($refInfos = $infos->getReferenceInfo()) && $refInfos->getIsMultiple()) {
                        $repository = $this->repositoryFactory->getRepository($this->documentManager, $refInfos->getDocument(), $refInfos->getCollection());

                        if (!$data[$field] instanceof \MongoDB\Model\BSONArray && !is_array($data[$field])) {
                            throw new \Exception("RefersMany value must be an array for document with '_id' : " . $data["_id"]);
                        } else {
                            $objectsDatas = $repository->getCollection()->find(["_id" => ['$in' => $data[$field]]]);
                        }

                        $objectArray = null;

                        if (!empty($objectsDatas)) {
                            $objectArray = [];
                            foreach ($objectsDatas as $objectDatas) {
                                $class = $refInfos->getDocument();

                                if (!class_exists($class)) {
                                    $class = $this->classMetadata->getNamespace() . "\\" . $class;
                                }

                                $referedObject = new $class();

                                $hydrator = $repository->getHydrator();
                                $hydrator->hydrate($referedObject, $objectDatas, $soft, $maxReferenceDepth - 1);

                                $objectArray[] = $referedObject;
                            }
                        }
                        $data[$field] = $objectArray;
                    }

                    $this->setValue($object, $data[$field], $setter, $prop);
                }
            }
        }
    }
111122
private static function doDump(&$data, $object)
    {
        if (is_object($object) && static::$objectStorage->contains($object)) {
            $data = null;

            return;
        }

        if (is_object($object)) {
            static::$objectStorage->attach($object);
        }

        if (is_array($object) || $object instanceof \Traversable) {
            foreach ($object as $key => $value) {
                static::doDump($data[$key], $value);
            }
        } elseif (is_object($object)) {
            $ref = new \ReflectionObject($object);

            $properties = $ref->getProperties();

            foreach ($properties as $property) {
                $property->setAccessible(true);

                $value = $property->getValue($object);

                static::doDump($data[$property->getName()], $value);
            }
        } else {
            $data = $object;
        }
    }
719485
private function hydrate($object_data) {
    //if (is_array($object_data)) {
      foreach ($object_data as $object_data_key => $object_data_value) {
        if(method_exists($this, $object_data_key)) {
          if ($object_data_value == '') {
            $object_data_value = null;
          }
          $this->{'set'.ucfirst($object_data_key)}($object_data_value);
        }
      }
    //}
    /* else if (is_a($object_data, get_class($this))) {
      foreach ($this->properties() as $properties_key => $properties_value) {
        $this->{'set'.ucfirst($properties_value)}($object_data->$properties_value());
      }
    }/* else {
      throw new XException('00010003', 4, array( 0 => get_class($this) ));
    }*/
  }
236822
public function hydrate(array $data, $object)
    {
        parent::hydrate($data, $object);
        $object->setEnvironment($object->getFact(NodeInterface::ENVIRONMENT_FACT));
        return $object;
    }
1049077
public function hydrate(array $data, $object)
    {
        if (!isset($data['track'])) {
            return $object;
        }

        $hydrators = new AggregateHydrator();
        $hydrators->add(new TrackHydrator());
        $hydrators->add(new AlbumAwareHydrator());
        $hydrators->add(new ArtistCollectionAwareHydrator());
        $hydrators->add(new ImageCollectionAwareHydrator());

        $object->setTrack($hydrators->hydrate($data['track'], new Track()));

        return $object;
    }
11311
public function hydrate(array $data, $object)
    {
        if (!isset($data['album'])) {
            return $object;
        }

        $hydrators = new AggregateHydrator();
        $hydrators->add(new AlbumHydrator());
        $hydrators->add(new ImageCollectionAwareHydrator());

        $object->setAlbum($hydrators->hydrate($data['album'], new Album()));

        return $object;
    }
781974
protected function populate(AbstractResponse $object, array $data)
    {
        $reflect = new ReflectionClass($object);

        $properties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);

        foreach ($properties as $property) {
            if (array_key_exists($property->name, $data)) {
                $object->{$property->name} = $this->getValueByAnnotatedType($property, $data[$property->name]);
            }
        }

        return $object;
    }
53983
public function hydrate(array $data, $object)
    {
        if (!$object instanceof UserBlock) {
            throw new \Exception('$object must be an instance of UserBlock');
        }

        return parent::hydrate($data, $object);
    }
1011286
public function hydrate(array $data, $object)
    {
        if (! $object instanceof Entity) {
            return $object;
        }
                
        parent::hydrate($data, $object);
               
        $authEntity = parent::hydrate($data, new \Pacificnm\Auth\Entity\Entity());
        
        $object->setAuthEntity($authEntity);
        
        $aclRoleEntity = parent::hydrate($data, new \Pacificnm\AclRole\Entity\Entity());
        
        $object->getAuthEntity()->setAclRoleEntity($aclRoleEntity);
        
        return $object;
    }
319179
protected function doHydrate(array $data, $object)
    {
        $previousHydrationContext = $this->currentHydrationContext;
        $this->currentHydrationContext = new CurrentHydrationContext($data, $object);

        foreach ($this->metadata->getMappedFieldNames() as $mappedFieldName) {
            $defaultValue = $this->metadata->getFieldDefaultValue($mappedFieldName);

            if (null !== $defaultValue) {
                $this->resolveValue($defaultValue, $object);
                $this->memberAccessStrategy->setValue($defaultValue, $object, $mappedFieldName);   
            }
        }

        if (! $this->metadata->hasCustomHydrator()) {

            $this->executeMethods($object, $this->metadata->getPreHydrateListeners());

            foreach ($data as $originalFieldName => $value) {
                $mappedFieldName = $this->metadata->getMappedFieldName($originalFieldName);
                if (null === $mappedFieldName) {

                    //It's possible that a raw field name has no corresponding field name
                    //because a raw field can be a value object part.
                    continue;
                }

                if (! $this->metadata->hasSource($mappedFieldName)) {
                    //Classical hydration.
                    $this->walkHydration($mappedFieldName, $object, $value, $data);
                }
            }
        } else {
            list($customHydratorClass, $customHydrateMethod) = $this->metadata->getCustomHydratorInfo();
            $this->executeMethod($object, new ClassMetadata\Model\Method($customHydratorClass, $customHydrateMethod, [$data, $object]));
        }

        //DataSources hydration.
        foreach ($this->metadata->getFieldsWithDataSources() as $mappedFieldName) {

            if ($this->metadata->hasDataSource($mappedFieldName)) {//<= Is this test usefull ?
                $this->walkHydrationByDataSource($mappedFieldName, $object, false);
            }
        }

        //Providers hydration.
        foreach ($this->metadata->getFieldsWithProviders() as $mappedFieldName) {

            if ($this->metadata->hasProvider($mappedFieldName)) {//<= Is this test usefull ?
                $this->walkHydrationByProvider($mappedFieldName, $object, false);
            }
        }

        //Value objects hydration.
        foreach ($this->metadata->getFieldsWithValueObjects() as $mappedFieldName) {
            $this->walkValueObjectHydration($mappedFieldName, $object, $data);
        }

        $this->executeMethods($object, $this->metadata->getPostHydrateListeners());

        $this->currentHydrationContext = $previousHydrationContext;

        return $object;
    }