diff --git a/Lib/Formatter/Html.php b/Lib/Formatter/Html.php index 166d201..72db84a 100644 --- a/Lib/Formatter/Html.php +++ b/Lib/Formatter/Html.php @@ -10,11 +10,36 @@ class Html extends Formatter { )); } + protected function truncate($v, $ellipsis = ' [...]') { + $limit = 50; + if(strlen($v) > $limit) { + $v = substr($v, 0, $limit).$ellipsis; + } + return $v; + } + + protected function formatValue($v) { + if(is_numeric($v)) { + return $v; + } + if(is_bool($v)) { + return ''; + } + if(is_string($v) && strpos($v, 'http') !== false) { + $url = $v; + $v = $this->truncate($v, '...'); + return "$v"; + } + + return $this->truncate(print_r($v, true)); + } + protected function result($data) { // the format is array('result' => array('function name' => DATA)) // so take the first element of the 'result' array $func = key($data['result']); $data = reset($data['result']); + $title = $func; $first = reset($data); $single = ! is_array($first); @@ -25,6 +50,8 @@ class Html extends Formatter { } else { $columns = array_keys($first); + $title .= ' ('.count($data).' results)'; + $content .= '