flight\core\Dispatcher::execute PHP Method

execute() public static method

Executes a callback function.
public static execute ( callback $callback, array &$params = [] ) : mixed
$callback callback Callback function
$params array Function parameters
return mixed Function results
    public static function execute($callback, array &$params = array())
    {
        if (is_callable($callback)) {
            return is_array($callback) ? self::invokeMethod($callback, $params) : self::callFunction($callback, $params);
        } else {
            throw new \Exception('Invalid callback specified.');
        }
    }

Usage Example

Beispiel #1
0
 function testInvalidCallback()
 {
     $this->setExpectedException('Exception', 'Invalid callback specified.');
     $this->dispatcher->execute(array('NonExistentClass', 'nonExistentMethod'));
 }