Completed
Push — 57-formatter-per-extension ( 73b3c8 )
by Nicolas
40:17 queued 36:16
created

IncludeParser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Karma\Configuration\Parser;
4
5
class IncludeParser extends AbstractSectionParser
6
{
7
    private
8
        $files;
9
    
10
    public function __construct()
11
    {
12
        $this->files = array();
13
    }
14
    
15
    protected function parseLine($line)
16
    {
17
        if($this->isACommentLine($line))
18
        {
19
            return true;
20
        }
21
                
22
        $this->checkFilenameIsValid($line);
23
        
24
        $this->files[] = $line;
25
    }
26
    
27
    private function checkFilenameIsValid($filename)
28
    {
29
        if(! preg_match('~.*\.conf$~', $filename))
30
        {
31
            $this->triggerError("$filename is not a valid file name", 'Invalid dependency');   
32
        }
33
    }
34
    
35
    public function getCollectedFiles()
36
    {
37
        return $this->files;
38
    }
39
}