public function specEnd($log = null)
{
$isOk = $log->passed() ? "ok" : "not ok";
switch ($log->type()) {
case 'skipped':
case 'pending':
case 'excluded':
$prefix = "# {$log->type()} ";
break;
default:
$prefix = '- ';
break;
}
$message = $prefix . trim(implode(" ", $log->messages()));
$this->_counter++;
$this->write("{$isOk} {$this->_counter} {$message}\n");
if ($exception = $log->exception()) {
$this->write('# Exception: `' . get_class($exception) . '` Code(' . $exception->getCode() . '):' . "\n");
$this->write('# Message: ' . $exception->getMessage() . "\n");
} else {
foreach ($log->children() as $log) {
if ($log->passed()) {
continue;
}
$toString = function ($instance) {
return 'an instance of `' . get_class($instance) . '`';
};
foreach ($log->data() as $key => $value) {
$key = ucfirst($key);
$value = Text::toString($value, ['object' => ['method' => $toString]]);
$this->write("# {$key}: {$value}\n");
}
}
}
}