CsvtoArray   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 10
dl 0
loc 18
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A csv_to_array() 0 16 5
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