Eloquent\Phony\Verification\GeneratorVerifier::checkReturned PHP Метод

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

Checks if the subject returned the supplied value from a generator.
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();
        if ($this->subject instanceof Call) {
            $cardinality->assertSingular();
        }
        $matchingEvents = array();
        $matchCount = 0;
        if (0 === func_num_args()) {
            foreach ($this->calls as $call) {
                if (!$call->isGenerator() || !($endEvent = $call->endEvent())) {
                    continue;
                }
                list($exception) = $call->generatorResponse();
                if (!$exception) {
                    $matchingEvents[] = $endEvent;
                    ++$matchCount;
                }
            }
        } else {
            $value = $this->matcherFactory->adapt($value);
            foreach ($this->calls as $call) {
                if (!$call->isGenerator() || !($endEvent = $call->endEvent())) {
                    continue;
                }
                list($exception, $returnValue) = $call->generatorResponse();
                if (!$exception && $value->matches($returnValue)) {
                    $matchingEvents[] = $endEvent;
                    ++$matchCount;
                }
            }
        }
        if ($cardinality->matches($matchCount, $this->callCount)) {
            return $this->assertionRecorder->createSuccess($matchingEvents);
        }
    }