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);
}
}