Conditions | 5 |
Paths | 2 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
54 | 1 | public function readFile($path, $hasHeader = true) { |
|
55 | 1 | $header = null; |
|
56 | |||
57 | 1 | $data = []; |
|
58 | |||
59 | 1 | if (($handle = fopen($path, 'r')) !== false) { |
|
60 | 1 | while (($row = fgetcsv($handle)) !== false) { |
|
61 | 1 | if (! $header && $hasHeader) { |
|
62 | 1 | $header = $row; |
|
63 | 1 | } else { |
|
64 | 1 | $assoc = array_combine($header, $row); |
|
65 | 1 | $assoc['created_at'] = $assoc['updated_at'] = Carbon::now(); |
|
66 | |||
67 | 1 | $data[] = $assoc; |
|
68 | } |
||
69 | 1 | } |
|
70 | 1 | fclose($handle); |
|
71 | 1 | } |
|
72 | |||
73 | 1 | return $data; |
|
74 | } |
||
75 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.