public function stats()
{
$results = (array) $this->results['group'];
$defaults = array('asserts' => 0, 'passes' => array(), 'fails' => array(), 'exceptions' => array(), 'errors' => array(), 'skips' => array());
$stats = array_reduce($results, function ($stats, $result) use($defaults) {
$stats = (array) $stats + $defaults;
$result = empty($result[0]) ? array($result) : $result;
foreach ($result as $response) {
if (empty($response['result'])) {
continue;
}
$result = $response['result'];
if (in_array($result, array('fail', 'exception'))) {
$response = array_merge(array('class' => 'unknown', 'method' => 'unknown'), $response);
$stats['errors'][] = $response;
}
unset($response['file'], $response['result']);
if (in_array($result, array('pass', 'fail'))) {
$stats['asserts']++;
}
if (in_array($result, array('pass', 'fail', 'exception', 'skip'))) {
$stats[Inflector::pluralize($result)][] = $response;
}
}
return $stats;
});
$stats = (array) $stats + $defaults;
$count = array_map(function ($value) {
return is_array($value) ? count($value) : $value;
}, $stats);
$success = $count['passes'] === $count['asserts'] && $count['errors'] === 0;
return compact('stats', 'count', 'success');
}