Passed
Push — master ( 94b934...c658e2 )
by Marius
04:22 queued 42s
created

ExtendedWriter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 26
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A add() 0 22 5
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\PhpStormHelper\Service\Gitignore;
5
6
use GitIgnoreWriter\GitIgnoreWriter;
7
8
class ExtendedWriter extends GitIgnoreWriter
9
{
10
11 9
    public function add($input)
12
    {
13 9
        $inputLines = $this->parseInput($input);
14
15 9
        $commentSection = [];
16 9
        $lines = [];
17 9
        foreach($inputLines as $k => $line) {
18 8
            if ($line === '' || $line[0] === '#') {
19 7
                $commentSection[] = $line;
20 7
                continue;
21
            }
22
23 8
            if (!$this->exists($line)) {
24 7
                $lines = array_merge($lines, $commentSection);
25 7
                $lines[] = $line;
26
            }
27
28 8
            $commentSection = [];
29
        }
30
31 9
        return parent::add($lines);
32
    }
33
}
34