Eloquent\Phony\Spy\SpyVerifier::checkGenerated PHP Method

checkGenerated() public method

Checks if this spy returned a generator.
public checkGenerated ( ) : GeneratorVerifier | null
return Eloquent\Phony\Verification\GeneratorVerifier | null The result.
    public function checkGenerated()
    {
        $cardinality = $this->resetCardinality();
        $calls = $this->spy->allCalls();
        $matchingEvents = array();
        $totalCount = count($calls);
        $matchCount = 0;
        foreach ($calls as $call) {
            if (!$call->responseEvent()) {
                continue;
            }
            list(, $returnValue) = $call->response();
            if ($returnValue instanceof Generator) {
                $matchingEvents[] = $call;
                ++$matchCount;
            }
        }
        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccessFromEventCollection($this->generatorVerifierFactory->create($this->spy, $matchingEvents));
        }
    }