Spot\Query::__call PHP Method

__call() public method

Run user-added callback
public __call ( string $method, array $args ) : mixed
$method string Method name called
$args array Array of arguments used in missing method call
return mixed
    public function __call($method, $args)
    {
        $scopes = $this->mapper()->scopes();
        // Custom methods
        if (isset(self::$_customMethods[$method]) && is_callable(self::$_customMethods[$method])) {
            $callback = self::$_customMethods[$method];
            // Pass the current query object as the first parameter
            array_unshift($args, $this);
            return call_user_func_array($callback, $args);
            // Scopes
        } elseif (isset($scopes[$method])) {
            // Pass the current query object as the first parameter
            array_unshift($args, $this);
            return call_user_func_array($scopes[$method], $args);
            // Methods on Collection
        } elseif (method_exists('\\Spot\\Entity\\Collection', $method)) {
            return call_user_func_array([$this->execute(), $method], $args);
            // Error
        } else {
            throw new \BadMethodCallException("Method '" . __CLASS__ . "::" . $method . "' not found");
        }
    }