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

checkCompleted() public method

Checks if this spy completed.
public checkCompleted ( ) : Eloquent\Phony\Event\EventCollection | null
return Eloquent\Phony\Event\EventCollection | null The result.
    public function checkCompleted()
    {
        $cardinality = $this->resetCardinality();
        $calls = $this->spy->allCalls();
        $matchingEvents = array();
        $totalCount = count($calls);
        $matchCount = 0;
        foreach ($calls as $call) {
            if ($endEvent = $call->endEvent()) {
                $matchingEvents[] = $endEvent;
                ++$matchCount;
            }
        }
        if ($cardinality->matches($matchCount, $totalCount)) {
            return $this->assertionRecorder->createSuccess($matchingEvents);
        }
    }