Phockito::__called PHP Method

__called() public static method

Called by the mock instances when a method is called. Records the call and returns a response if one has been stubbed in
public static __called ( $class, $instance, $method, $args )
    public static function __called($class, $instance, $method, $args)
    {
        // Record the call as most recent first
        array_unshift(self::$_call_list, array('class' => $class, 'instance' => $instance, 'method' => $method, 'args' => $args));
        // Look up any stubbed responses
        if (isset(self::$_responses[$instance][$method])) {
            // Find the first one that matches the called-with arguments
            foreach (self::$_responses[$instance][$method] as $i => &$matcher) {
                if (self::_arguments_match($class, $method, $matcher['args'], $args)) {
                    // Consume the next response - except the last one, which repeats indefinitely
                    if (count($matcher['steps']) > 1) {
                        return array_shift($matcher['steps']);
                    } else {
                        return reset($matcher['steps']);
                    }
                }
            }
        }
    }