lithium\test\Mocker::callFunction()

public static method

A method to call user defined functions.

This method should only be accessed by functions created by Mocker::overwriteFunction().

If no matching stored function exists, the global function will be called instead.

Parameters

  • string $name

    Fully namespaced function name to call.

  • array

    $params Params to be passed to the function.

Returns

mixed

Source

	public static function callFunction($name, array &$params = []) {
		$function = substr($name, strrpos($name, '\\'));
		$exists = isset(static::$_functionCallbacks[$name]);
		if ($exists && is_callable(static::$_functionCallbacks[$name])) {
			$function = static::$_functionCallbacks[$name];
		}
		$result = call_user_func_array($function, $params);
		if (!isset(static::$_functionResults[$name])) {
			static::$_functionResults[$name] = [];
		}
		static::$_functionResults[$name][] = [
			'args' => $params,
			'result' => $result,
			'time' => microtime(true),
		];
		return $result;
	}