Eloquent\Phony\Spy\SpyVerifier::checkReturned PHP Метод

checkReturned() публичный Метод

Checks if this spy returned the supplied value.
public checkReturned ( mixed $value = null ) : Eloquent\Phony\Event\EventCollection | null
$value mixed The value.
Результат Eloquent\Phony\Event\EventCollection | null The result.
    public function checkReturned($value = null)
    {
        $cardinality = $this->resetCardinality();
        $calls = $this->spy->allCalls();
        $matchingEvents = array();
        $totalCount = count($calls);
        $matchCount = 0;
        if (0 === func_num_args()) {
            foreach ($calls as $call) {
                if (!($responseEvent = $call->responseEvent())) {
                    continue;
                }
                list($exception) = $call->response();
                if (!$exception) {
                    $matchingEvents[] = $responseEvent;
                    ++$matchCount;
                }
            }
        } else {
            $value = $this->matcherFactory->adapt($value);
            foreach ($calls as $call) {
                if (!($responseEvent = $call->responseEvent())) {
                    continue;
                }
                list($exception, $returnValue) = $call->response();
                if (!$exception && $value->matches($returnValue)) {
                    $matchingEvents[] = $responseEvent;
                    ++$matchCount;
                }
            }
        }
        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccess($matchingEvents);
        }
    }