ExtendedWriter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
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 25
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 5
    public function add($input)
11
    {
12 5
        $inputLines = $this->parseInput($input);
13
14 5
        $commentSection = [];
15 5
        $lines = [];
16 5
        foreach ($inputLines as $k => $line) {
17 4
            if ($line === '' || $line[0] === '#') {
18 3
                $commentSection[] = $line;
19 3
                continue;
20
            }
21
22 4
            if (!$this->exists($line)) {
23 3
                $lines = array_merge($lines, $commentSection);
24 3
                $lines[] = $line;
25
            }
26
27 4
            $commentSection = [];
28
        }
29
30 5
        return parent::add($lines);
31
    }
32
}
33