Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.0961 |
Changes | 0 |
1 | <?php |
||
16 | 2 | public function read(string $absolutePath): array |
|
17 | { |
||
18 | 2 | if (!is_file($absolutePath)) { |
|
19 | return []; |
||
20 | } |
||
21 | |||
22 | 2 | $config = []; |
|
23 | 2 | $lines = file($absolutePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
24 | |||
25 | 2 | foreach ($lines as $line) { |
|
26 | 2 | if (strpos(trim($line), '#') === 0) { |
|
27 | continue; |
||
28 | } |
||
29 | |||
30 | 2 | [$name, $value] = explode('=', $line, 2); |
|
31 | 2 | $config[trim($name)] = trim($value); |
|
32 | } |
||
33 | |||
34 | 2 | return $config; |
|
35 | } |
||
37 |