LeanMapper\Entity::getHasOneValue PHP Method

getHasOneValue() private method

private getHasOneValue ( Property $property, HasOne $relationship, Filtering $filtering = null ) : Entity
$property LeanMapper\Reflection\Property
$relationship LeanMapper\Relationship\HasOne micro-optimalization
$filtering Filtering
return Entity
    private function getHasOneValue(Property $property, Relationship\HasOne $relationship, Filtering $filtering = null)
    {
        $targetTable = $relationship->getTargetTable();
        $row = $this->row->referenced($targetTable, $relationship->getColumnReferencingTargetTable(), $filtering);
        if ($row === null) {
            if (!$property->isNullable()) {
                $name = $property->getName();
                throw new InvalidValueException("Property '{$name}' cannot be null in entity " . get_called_class() . '.');
            }
            return null;
        } else {
            $entityClass = $this->mapper->getEntityClass($targetTable, $row);
            $entity = $this->entityFactory->createEntity($entityClass, $row);
            $this->checkConsistency($property, $entityClass, $entity);
            $entity->makeAlive($this->entityFactory);
            return $entity;
        }
    }