public function hydrate($data = [], $option = self::HYDRATE_AUTO)
{
$option = $this->determineOption($data, $option);
switch ($option) {
case self::HYDRATE_RAW:
return $data;
//if entity set has many items, return a collection of entities
//if entity set has many items, return a collection of entities
case self::HYDRATE_COLLECTION:
return $this->hydrateCollection($data);
//if entity has one item, return the entity
//if entity has one item, return the entity
case self::HYDRATE_ENTITY:
$data = $this->isCollectable($data) ? array_shift($data) : $data;
return $this->hydrateEntity($data);
}
throw new \LogicException('Unknown option ' . $option);
}