Completed
Branch 09branch (0a5c88)
by Anton
05:50
created

Parser::parseLine()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 2
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
namespace Spiral\Core\Environment;
9
10
use Dotenv\Loader;
11
12
/**
13
 * Lower level access to env variables. Built at top of Dotenv package.
14
 */
15
class Parser extends Loader
16
{
17
    /**
18
     * Parse environment file and return it's values.
19
     *
20
     * @return array
21
     */
22
    public function parse(): array
23
    {
24
        $values = [];
25
26
        $lines = $this->readLinesFromFile($this->filePath);
27
        foreach ($lines as $line) {
28
            if ($this->isComment($line)) {
29
                continue;
30
            }
31
32
            if ($this->looksLikeSetter($line)) {
33
                list($name, $value) = $this->normaliseEnvironmentVariable($line, null);
34
                $values[$name] = $value;
35
            }
36
        }
37
38
        return $values;
39
    }
40
}