GitIgnoreListener::addNewInstalledFiles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 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