src/Plugin/Call/Calls.php
public static function find($message, $index = 0, $times = 0, &$args = [])
    {
        $success = false;
        $messages = !is_array($message) ? [$message] : $message;

        $message = reset($messages);
        $reference = $message->reference();
        $reference = $message->isStatic() && is_object($reference) ? get_class($reference) : $reference;

        $lastFound = null;

        $count = count(static::$_logs);

        for ($i = $index; $i < $count; $i++) {
            $logs = static::$_logs[$i];
            if (!$log = static::_matchReference($reference, $logs)) {
                continue;
            }

            if (!$message->match($log, false)) {
                continue;
            }
            $args[] = $log['args'];

            if (!$message->matchArgs($log['args'])) {
                continue;
            }

            if ($message = next($messages)) {
                $lastFound = $message;
                if (!$reference = $message->reference() && $log['method']) {
                    $reference = $log['method']->actualReturn();
                }
                if (!is_object($reference)) {
                    $message = reset($messages);
                    $reference = $message->reference();
                }
                $reference = $message->isStatic() && is_object($reference) ? get_class($reference) : $reference;
                continue;
            }

            $times -= 1;
            if ($times < 0) {
                $success = true;
                static::find($messages, $i + 1, 0, $args);
                static::$_index = $i + 1;
                break;
            } elseif ($times === 0) {
                $next = static::find($messages, $i + 1, 0, $args);
                if ($next['success']) {
                    $success = false;
                } else {
                    $success = true;
                    static::$_index = $i + 1;
                }
                break;
            }
            return static::find($messages, $i + 1, $times, $args);
        }
        $index = static::$_index;
        $message = $lastFound ?: reset($messages);
        return compact('success', 'message', 'args', 'index');
    }
public static function find($message, $index = 0, $times = 0, &$args = [])
    {
        $success = false;
        $messages = !is_array($message) ? [$message] : $message;

        $message = reset($messages);
        $reference = $message->reference();
        $reference = $message->isStatic() && is_object($reference) ? get_class($reference) : $reference;

        $lastFound = null;

        $count = count(static::$_logs);

        for ($i = $index; $i < $count; $i++) {
            $logs = static::$_logs[$i];
            if (!$log = static::_matchReference($reference, $logs)) {
                continue;
            }

            if (!$message->match($log, false)) {
                continue;
            }
            $args[] = $log['args'];

            if (!$message->matchArgs($log['args'])) {
                continue;
            }

            if ($message = next($messages)) {
                $lastFound = $message;
                if (!$reference = $message->reference() && $log['method']) {
                    $reference = $log['method']->actualReturn();
                }
                if (!is_object($reference)) {
                    $message = reset($messages);
                    $reference = $message->reference();
                }
                $reference = $message->isStatic() && is_object($reference) ? get_class($reference) : $reference;
                continue;
            }

            $times -= 1;
            if ($times < 0) {
                $success = true;
                static::find($messages, $i + 1, 0, $args);
                static::$_index = $i + 1;
                break;
            } elseif ($times === 0) {
                $next = static::find($messages, $i + 1, 0, $args);
                if ($next['success']) {
                    $success = false;
                } else {
                    $success = true;
                    static::$_index = $i + 1;
                }
                break;
            }
            return static::find($messages, $i + 1, $times, $args);
        }
        $index = static::$_index;
        $message = $lastFound ?: reset($messages);
        return compact('success', 'message', 'args', 'index');
    }
public static function find ( $ message , $ index = 0 , $ times = 0 , & $ args = [ ] ) { $ success = false ; $ messages = ! is_array ( $ message ) ? [ $ message ] : $ message ; $ message = reset ( $ messages ) ; $ reference = $ message -> reference ( ) ; $ reference = $ message -> isStatic ( ) && is_object ( $ reference ) ? get_class ( $ reference ) : $ reference ; $ lastFound = null ; $ count = count ( static :: $ _logs ) ; for ( $ i = $ index ; $ i < $ count ; $ i ++ ) { $ logs = static :: $ _logs [ $ i ] ; if ( ! $ log = static :: _matchReference ( $ reference , $ logs ) ) { continue ; } if ( ! $ message -> match ( $ log , false ) ) { continue ; } $ args [ ] = $ log [ 'args' ] ; if ( ! $ message -> matchArgs ( $ log [ 'args' ] ) ) { continue ; } if ( $ message = next ( $ messages ) ) { $ lastFound = $ message ; if ( ! $ reference = $ message -> reference ( ) && $ log [ 'method' ] ) { $ reference = $ log [ 'method' ] -> actualReturn ( ) ; } if ( ! is_object ( $ reference ) ) { $ message = reset ( $ messages ) ; $ reference = $ message -> reference ( ) ; } $ reference = $ message -> isStatic ( ) && is_object ( $ reference ) ? get_class ( $ reference ) : $ reference ; continue ; } $ times -= 1 ; if ( $ times < 0 ) { $ success = true ; static :: find ( $ messages , $ i + 1 , 0 , $ args ) ; static :: $ _index = $ i + 1 ; break ; } elseif ( $ times === 0 ) { $ next = static :: find ( $ messages , $ i + 1 , 0 , $ args ) ; if ( $ next [ 'success' ] ) { $ success = false ; } else { $ success = true ; static :: $ _index = $ i + 1 ; } break ; } return static :: find ( $ messages , $ i + 1 , $ times , $ args ) ; } $ index = static :: $ _index ; $ message = $ lastFound ? : reset ( $ messages ) ; return compact ( 'success' , 'message' , 'args' , 'index' ) ; }
Finds a logged call.

@param  object      $message   The message method name.
@param  integer     $index     Start index.
@param  integer     $times
@param  array       $args      Populated by the list of passed arguments.
@return array|false            Return founded log call.
Finds a logged call .