Completed
Push — nln-php7 ( 311875...6680df )
by Nicolas
11:20
created

IncludeParser   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Karma\Configuration\Parser;
6
7
class IncludeParser extends AbstractSectionParser
8
{
9
    private array
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
10
        $files;
11
12 280
    public function __construct()
13
    {
14 280
        parent::__construct();
15
16 280
        $this->files = [];
17 280
    }
18
19 211
    protected function parseLine(string $line): void
20
    {
21 211
        $this->checkFilenameIsValid($line);
22
23 210
        $this->files[] = $line;
24 210
    }
25
26 211
    private function checkFilenameIsValid(string $filename): void
27
    {
28 211
        if(! preg_match('~.*\.conf$~', $filename))
29
        {
30 1
            $this->triggerError("$filename is not a valid file name", 'Invalid dependency');
31
        }
32 210
    }
33
34 248
    public function getCollectedFiles(): array
35
    {
36 248
        return $this->files;
37
    }
38
}
39