Passed
Push — main ( 57fd05...2c37f6 )
by Sammy
01:14
created

CSV::collection_of_models_to_csv()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 33
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 20
c 1
b 0
f 0
nc 6
nop 3
dl 0
loc 33
rs 9.6
1
<?php
2
3
namespace HexMakina\LocalFS\Text;
4
5
class CSV extends TextFile
6
{
7
8
9
  // T — Gets line from file pointer and parse for CSV fields
10
  // fgetcsv ( resource $handle [, int $length = 0 [, string $delimiter = "," [, string $enclosure = '"' [, string $escape = "\\" ]]]] ) : array
11
12
  // fputcsv ( resource $handle , array $fields [, string $delimiter = "," [, string $enclosure = '"' [, string $escape_char = "\\" ]]] ) : int
13
  /*
14
<?php
15
16
$list = array (
17
    array('aaa', 'bbb', 'ccc', 'dddd'),
18
    array('123', '456', '789'),
19
    array('"aaa"', '"bbb"')
20
);
21
22
$fp = fopen('file.csv', 'w');
23
24
foreach ($list as $fields) {
25
    fputcsv($fp, $fields);
26
}
27
28
fclose($fp);
29
30
31
*/
32
	function array()
33
	{
34
		return array_map('str_getcsv', parent::array());
35
	}
36
37
38
}
39