Doctrine\ODM\OrientDB\Mapper\Hydration\Hydrator::castProperty PHP Method

castProperty() protected method

Casts a value according to how it was annotated.
protected castProperty ( Property $annotation, mixed $propertyValue ) : mixed
$annotation Doctrine\ODM\OrientDB\Mapper\Annotations\Property
$propertyValue mixed
return mixed
    protected function castProperty($annotation, $propertyValue)
    {
        $propertyId = $this->getCastedPropertyCacheKey($annotation->type, $propertyValue);
        if (!isset($this->castedProperties[$propertyId])) {
            $method = 'cast' . $this->inflector->camelize($annotation->type);
            $this->getCaster()->setValue($propertyValue);
            $this->getCaster()->setProperty('annotation', $annotation);
            $this->verifyCastingSupport($this->getCaster(), $method, $annotation->type);
            $this->castedProperties[$propertyId] = $this->getCaster()->{$method}();
        }
        return $this->castedProperties[$propertyId];
    }