Passed
Push — nln-php7 ( 12eaac )
by Nicolas
05:28
created

IncludeParser   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 35
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parseLine() 0 11 2
A checkFilenameIsValid() 0 7 2
A getCollectedFiles() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Karma\Configuration\Parser;
6
7
class IncludeParser extends AbstractSectionParser
8
{
9
    private
10
        $files;
11
12 279
    public function __construct()
13
    {
14 279
        $this->files = array();
15 279
    }
16
17 211
    protected function parseLine($line)
18
    {
19 211
        if($this->isACommentLine($line))
20
        {
21 198
            return true;
22
        }
23
24 211
        $this->checkFilenameIsValid($line);
25
26 210
        $this->files[] = $line;
27 210
    }
28
29 211
    private function checkFilenameIsValid($filename)
30
    {
31 211
        if(! preg_match('~.*\.conf$~', $filename))
32
        {
33 1
            $this->triggerError("$filename is not a valid file name", 'Invalid dependency');
34
        }
35 210
    }
36
37 248
    public function getCollectedFiles()
38
    {
39 248
        return $this->files;
40
    }
41
}
42