public function checkReturned($value = null)
{
$cardinality = $this->resetCardinality()->assertSingular();
if ($responseEvent = $this->call->responseEvent()) {
list($exception, $returnValue) = $this->call->response();
$hasReturned = !$exception;
} else {
$returnValue = null;
$hasReturned = false;
}
if (0 === func_num_args()) {
list($matchCount, $matchingEvents) = $this->matchIf($responseEvent, $hasReturned);
if ($cardinality->matches($matchCount, 1)) {
return $this->assertionRecorder->createSuccess($matchingEvents);
}
return;
}
$value = $this->matcherFactory->adapt($value);
list($matchCount, $matchingEvents) = $this->matchIf($responseEvent, $hasReturned && $value->matches($returnValue));
if ($cardinality->matches($matchCount, 1)) {
return $this->assertionRecorder->createSuccess($matchingEvents);
}
}