GitignoreHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 30
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setupGitignore() 0 18 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Paysera\PhpStormHelper\Service;
5
6
use Paysera\PhpStormHelper\Service\Gitignore\ExtendedWriter;
7
use Symfony\Component\Filesystem\Filesystem;
8
9
class GitignoreHelper
10
{
11
    private $filesystem;
12
    private $gitignoreRules;
13
14 10
    public function __construct(Filesystem $filesystem, array $gitignoreRules)
15
    {
16 10
        $this->filesystem = $filesystem;
17 10
        $this->gitignoreRules = $gitignoreRules;
18 10
    }
19
20 5
    public function setupGitignore(string $gitignorePath)
21
    {
22 5
        if (!$this->filesystem->exists($gitignorePath)) {
23
            return;
24
        }
25
26 5
        $writer = new ExtendedWriter($gitignorePath);
27
        $writer
28 5
            ->delete('.idea')
29 5
            ->delete('.idea/')
30 5
            ->delete('.idea/*')
31 5
            ->delete('/.idea')
32 5
            ->delete('/.idea/')
33 5
            ->delete('/.idea/*')
34 5
            ->add($this->gitignoreRules)
35 5
            ->save()
36
        ;
37 5
    }
38
}
39