src/Verification/GeneratorVerifier.php
public function checkReturned($value = null): ?EventCollection
    {
        $cardinality = $this->resetCardinality();

        if ($this->subject instanceof Call) {
            $cardinality->assertSingular();
        }

        $matchingEvents = [];
        $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);
        }

        return null;
    }
public function checkReturned($value = null): ?EventCollection
    {
        $cardinality = $this->resetCardinality();

        if ($this->subject instanceof Call) {
            $cardinality->assertSingular();
        }

        $matchingEvents = [];
        $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);
        }

        return null;
    }
public function checkReturned ( $ value = null ) : ? EventCollection { $ cardinality = $ this -> resetCardinality ( ) ; if ( $ this -> subject instanceof Call ) { $ cardinality -> assertSingular ( ) ; } $ matchingEvents = [ ] ; $ 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 ) ; } return null ; }
Checks if the subject returned the supplied value from a generator.

@param mixed $value The value.

@return EventCollection|null The result.
Checks if the subject returned the supplied value from a generator .