/** * Retrieves the content. * * @return string */ public function getContent() { $records = $this->timer->getRecords(); if (empty($records)) { return 'No timer was started!'; } $head = '<thead><tr><th>Name</th><th>Calls</th><th>Average</th></thead>'; $body = '<tbody>'; $row = '<tr class="%s"><td>%s</td><td valign="top">%s</td><td valign="top">%s s</td></tr>'; $index = 0; foreach ($records as $name => $record) { $css = $index % 2 ? 'odd' : 'even'; $calls = $this->timer->getCalls($name); $body .= sprintf($row, $css, $name, $calls, round($record, 2)); $index += 1; } $body .= '</tbody>'; $content = sprintf('<table class="neat-table">%s%s</table>', $head, $body); return $content; }
/** * @test * @expectedException \Neat\Util\Exception\OutOfBoundsException */ public function getCalls_noRecordExists() { $this->subject->stop(); $this->subject->getCalls('Timer1'); }