| 1 | <?php |
| 2 | namespace Civi\CiUtil; |
| 3 | |
| 4 | /** |
| 5 | * Class ComparisonPrinter |
| 6 | * |
| 7 | * @package Civi\CiUtil |
| 8 | */ |
| 9 | class ComparisonPrinter { |
| 10 | var $headers; |
| 11 | var $hasHeader = FALSE; |
| 12 | |
| 13 | /** |
| 14 | * @param $headers |
| 15 | */ |
| 16 | public function __construct($headers) { |
| 17 | $this->headers = $headers; |
| 18 | } |
| 19 | |
| 20 | public function printHeader() { |
| 21 | if ($this->hasHeader) { |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | ## LEGEND |
| 26 | print "LEGEND\n"; |
| 27 | $i = 1; |
| 28 | foreach ($this->headers as $header) { |
| 29 | printf("% 2d: %s\n", $i, $header); |
| 30 | $i++; |
| 31 | } |
| 32 | print "\n"; |
| 33 | |
| 34 | ## HEADER |
| 35 | printf("%-90s ", 'TEST NAME'); |
| 36 | $i = 1; |
| 37 | foreach ($this->headers as $header) { |
| 38 | printf("%-10d ", $i); |
| 39 | $i++; |
| 40 | } |
| 41 | print "\n"; |
| 42 | |
| 43 | $this->hasHeader = TRUE; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @param $test |
| 48 | * @param $values |
| 49 | */ |
| 50 | public function printRow($test, $values) { |
| 51 | $this->printHeader(); |
| 52 | printf("%-90s ", $test); |
| 53 | foreach ($values as $value) { |
| 54 | printf("%-10s ", $value); |
| 55 | } |
| 56 | print "\n"; |
| 57 | } |
| 58 | |
| 59 | } |