LeanMapper\Entity::__get PHP Method

__get() public method

public __get ( string $name ) : mixed
$name string
return mixed
    public function __get($name)
    {
        $reflection = $this->getCurrentReflection();
        $nativeGetter = $reflection->getGetter('get' . ucfirst($name));
        if ($nativeGetter !== null) {
            try {
                return $nativeGetter->invoke($this);
                // filters arguments are not relevant here
            } catch (ReflectionException $e) {
                throw new MemberAccessException("Cannot invoke native getter of property '{$name}' in entity " . get_called_class() . '.');
            }
        }
        $property = $reflection->getEntityProperty($name);
        if ($property === null) {
            throw new MemberAccessException("Cannot access undefined property '{$name}' in entity " . get_called_class() . '.');
        }
        $customGetter = $property->getGetter();
        if ($customGetter !== null) {
            if (!method_exists($this, $customGetter)) {
                throw new InvalidMethodCallException("Missing getter method '{$customGetter}' in entity " . get_called_class() . '.');
            }
            return $this->{$customGetter}();
            // filters arguments are not relevant here
        }
        return $this->get($property);
    }