commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / Civi / CiUtil / CsvPrinter.php
1 <?php
2 namespace Civi\CiUtil;
3
4 /**
5 * Class CsvPrinter
6 *
7 * @package Civi\CiUtil
8 */
9 class CsvPrinter {
10 var $file;
11 var $headers;
12 var $hasHeader = FALSE;
13
14 /**
15 * @param $file
16 * @param $headers
17 */
18 public function __construct($file, $headers) {
19 $this->file = fopen($file, "w");
20 $this->headers = $headers;
21 }
22
23 public function printHeader() {
24 if ($this->hasHeader) {
25 return;
26 }
27
28 $headers = array_values($this->headers);
29 array_unshift($headers, 'TEST NAME');
30 fputcsv($this->file, $headers);
31
32 $this->hasHeader = TRUE;
33 }
34
35 /**
36 * @param $test
37 * @param $values
38 */
39 public function printRow($test, $values) {
40 $this->printHeader();
41 $row = $values;
42 array_unshift($row, $test);
43 fputcsv($this->file, $row);
44 }
45
46 }