src/Call/CallFactory.php
public function record(
        $callback,
        Arguments $arguments,
        SpyData $spy
    ): CallData {
        $originalArguments = $arguments->copy();

        $call = new CallData(
            $spy->nextIndex(),
            $this->eventFactory->createCalled($spy, $originalArguments)
        );
        $spy->addCall($call);

        $returnValue = null;
        $exception = null;

        try {
            $returnValue = $this->invoker->callWith($callback, $arguments);
        } catch (Throwable $exception) {
            // handled below
        }

        if ($exception) {
            $responseEvent = $this->eventFactory->createThrew($exception);
        } else {
            $responseEvent = $this->eventFactory->createReturned($returnValue);
        }

        $call->setResponseEvent($responseEvent);

        return $call;
    }
public function record(
        $callback,
        Arguments $arguments,
        SpyData $spy
    ): CallData {
        $originalArguments = $arguments->copy();

        $call = new CallData(
            $spy->nextIndex(),
            $this->eventFactory->createCalled($spy, $originalArguments)
        );
        $spy->addCall($call);

        $returnValue = null;
        $exception = null;

        try {
            $returnValue = $this->invoker->callWith($callback, $arguments);
        } catch (Throwable $exception) {
            // handled below
        }

        if ($exception) {
            $responseEvent = $this->eventFactory->createThrew($exception);
        } else {
            $responseEvent = $this->eventFactory->createReturned($returnValue);
        }

        $call->setResponseEvent($responseEvent);

        return $call;
    }
public function record ( $ callback , Arguments $ arguments , SpyData $ spy ) : CallData { $ originalArguments = $ arguments -> copy ( ) ; $ call = new CallData ( $ spy -> nextIndex ( ) , $ this -> eventFactory -> createCalled ( $ spy , $ originalArguments ) ) ; $ spy -> addCall ( $ call ) ; $ returnValue = null ; $ exception = null ; try { $ returnValue = $ this -> invoker -> callWith ( $ callback , $ arguments ) ; } catch ( Throwable $ exception ) { // handled below } if ( $ exception ) { $ responseEvent = $ this -> eventFactory -> createThrew ( $ exception ) ; } else { $ responseEvent = $ this -> eventFactory -> createReturned ( $ returnValue ) ; } $ call -> setResponseEvent ( $ responseEvent ) ; return $ call ; }
Record call details by invoking a callback.

@param callable  $callback  The callback.
@param Arguments $arguments The arguments.
@param SpyData   $spy       The spy to record the call to.

@return CallData The newly created call.
Record call details by invoking a callback .