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

IncludeParser   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 35
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A checkFilenameIsValid() 0 7 2
A getCollectedFiles() 0 4 1
A parseLine() 0 11 2
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
}