src/Spy/SpyVerifier.php
public function checkIterated(): ?IterableVerifier
    {
        $cardinality = $this->resetCardinality();

        $calls = $this->spy->allCalls();
        $matchingEvents = [];
        $totalCount = count($calls);
        $matchCount = 0;

        foreach ($calls as $call) {
            if (!$call->responseEvent()) {
                continue;
            }

            list(, $returnValue) = $call->response();

            if ($returnValue instanceof Traversable || is_array($returnValue)) {
                $matchingEvents[] = $call;
                ++$matchCount;
            }
        }

        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccessFromEventCollection(
                $this->iterableVerifierFactory
                    ->create($this->spy, $matchingEvents)
            );
        }

        return null;
    }
public function checkIterated(): ?IterableVerifier
    {
        $cardinality = $this->resetCardinality();

        $calls = $this->spy->allCalls();
        $matchingEvents = [];
        $totalCount = count($calls);
        $matchCount = 0;

        foreach ($calls as $call) {
            if (!$call->responseEvent()) {
                continue;
            }

            list(, $returnValue) = $call->response();

            if ($returnValue instanceof Traversable || is_array($returnValue)) {
                $matchingEvents[] = $call;
                ++$matchCount;
            }
        }

        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccessFromEventCollection(
                $this->iterableVerifierFactory
                    ->create($this->spy, $matchingEvents)
            );
        }

        return null;
    }
public function checkIterated ( ) : ? IterableVerifier { $ cardinality = $ this -> resetCardinality ( ) ; $ calls = $ this -> spy -> allCalls ( ) ; $ matchingEvents = [ ] ; $ totalCount = count ( $ calls ) ; $ matchCount = 0 ; foreach ( $ calls as $ call ) { if ( ! $ call -> responseEvent ( ) ) { continue ; } list ( , $ returnValue ) = $ call -> response ( ) ; if ( $ returnValue instanceof Traversable || is_array ( $ returnValue ) ) { $ matchingEvents [ ] = $ call ; ++ $ matchCount ; } } if ( $ cardinality -> matches ( $ matchCount , $ totalCount ) ) { return $ this -> assertionRecorder -> createSuccessFromEventCollection ( $ this -> iterableVerifierFactory -> create ( $ this -> spy , $ matchingEvents ) ) ; } return null ; }
Checks if this spy returned an iterable.

@return IterableVerifier|null The result.
Checks if this spy returned an iterable .