(NFC) Upgrade Civi Folder to the new coder version
[civicrm-core.git] / Civi / CiUtil / CSVParser.php
1 <?php
2 namespace Civi\CiUtil;
3
4 /**
5 * Parse phpunit result files
6 */
7 class CSVParser {
8
9 /**
10 * @param string $csvContent
11 * Content; each row in the row csv should start with two cells:.
12 * - cell 0: the test name
13 * - cell 1: the test status
14 * @return array
15 * (string $testName => string $status)
16 */
17 public static function parseResults($csvContent) {
18 $fh = fopen('php://memory', 'r+');
19 fwrite($fh, $csvContent);
20 rewind($fh);
21
22 $results = [];
23 while (($r = fgetcsv($fh)) !== FALSE) {
24 $name = str_replace('.', '::', trim($r[0]));
25 $status = trim($r[1]);
26 $results[$name] = $status;
27 }
28
29 return $results;
30 }
31
32 }