GitIgnoreListener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 40
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A removeUnInstalledFiles() 0 5 1
A addNewInstalledFiles() 0 7 1
1
<?php
2
3
namespace MagentoHackathon\Composer\Magento;
4
5
use MagentoHackathon\Composer\Magento\Event\PackageDeployEvent;
6
use MagentoHackathon\Composer\Magento\Event\PackageUnInstallEvent;
7
8
/**
9
 * Class GitIgnoreListener
10
 * @package MagentoHackathon\Composer\Magento
11
 * @author  Aydin Hassan <[email protected]>
12
 */
13
class GitIgnoreListener
14
{
15
16
    /**
17
     * @var GitIgnore
18
     */
19
    protected $gitIgnore;
20
21
    /**
22
     * @param GitIgnore $gitIgnore
23
     */
24 3
    public function __construct(GitIgnore $gitIgnore)
25
    {
26 3
        $this->gitIgnore = $gitIgnore;
27 3
    }
28
29
    /**
30
     * Add any files which were installed to the .gitignore
31
     *
32
     * @param PackageDeployEvent $packageDeployEvent
33
     */
34 1
    public function addNewInstalledFiles(PackageDeployEvent $packageDeployEvent)
35
    {
36 1
        $this->gitIgnore->addMultipleEntries(
37 1
            $packageDeployEvent->getDeployEntry()->getDeployStrategy()->getDeployedFiles()
38
        );
39 1
        $this->gitIgnore->write();
40 1
    }
41
42
    /**
43
     * Remove any files which were removed to the .gitignore
44
     *
45
     * @param PackageUnInstallEvent $e
46
     */
47 1
    public function removeUnInstalledFiles(PackageUnInstallEvent $e)
48
    {
49 1
        $this->gitIgnore->removeMultipleEntries($e->getInstalledFiles());
50 1
        $this->gitIgnore->write();
51 1
    }
52
}
53