CsvtoArray::csv_to_array()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 16
c 0
b 0
f 0
rs 9.6111
cc 5
nc 3
nop 2
1
<?php
2
3
namespace Turahe\Master\Seeds;
4
5
class CsvtoArray
6
{
7
    public function csv_to_array($filename, $header)
8
    {
9
        $delimiter = ',';
10
        if (!file_exists($filename) || !is_readable($filename)) {
11
            return false;
12
        }
13
14
        $data = [];
15
        if (($handle = fopen($filename, 'r')) !== false) {
16
            while (($row = fgetcsv($handle, 1000, $delimiter)) !== false) {
17
                $data[] = array_combine($header, $row);
18
            }
19
            fclose($handle);
20
        }
21
22
        return $data;
23
    }
24
}
25