Passed
Push — master ( 0a5eea...d0bbca )
by Ashoka
11:16 queued 08:32
created

Plugin::uninstall()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Mediact\TestingSuite\Composer;
4
5
use Composer\Composer;
6
use Composer\EventDispatcher\EventSubscriberInterface;
7
use Composer\IO\IOInterface;
8
use Composer\Plugin\PluginInterface;
9
use Mediact\TestingSuite\Composer\Installer\InstallerInterface;
10
11
/**
12
 * @SuppressWarnings(PHPMD.ShortVariable)
13
 */
14
class Plugin implements PluginInterface, EventSubscriberInterface
15
{
16
    /** @var InstallerInterface[] */
17
    private $installers;
18
19
    /**
20
     * Constructor.
21
     *
22
     * @param InstallerInterface[] ...$installers
23
     */
24 1
    public function __construct(InstallerInterface ...$installers)
25
    {
26 1
        $this->installers = $installers;
27 1
    }
28
29
    /**
30
     * Apply plugin modifications to Composer.
31
     *
32
     * @param Composer    $composer
33
     * @param IOInterface $io
34
     *
35
     * @return void
36
     */
37 1
    public function activate(Composer $composer, IOInterface $io)
38
    {
39 1
        $this->addInstallers(
40 1
            ...include __DIR__ . '/installers.php'
41
        );
42 1
    }
43
44
    /**
45
     * Remove any hooks from Composer.
46
     *
47
     * @param Composer    $composer
48
     * @param IOInterface $io
49
     *
50
     * @return void
51
     */
52
    public function deactivate(Composer $composer, IOInterface $io)
0 ignored issues
show
Unused Code introduced by
The parameter $io is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

52
    public function deactivate(Composer $composer, /** @scrutinizer ignore-unused */ IOInterface $io)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $composer is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

52
    public function deactivate(/** @scrutinizer ignore-unused */ Composer $composer, IOInterface $io)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
    }
55
56
    /**
57
     * Prepare the plugin to be uninstalled
58
     *
59
     * @param Composer    $composer
60
     * @param IOInterface $io
61
     *
62
     * @return void
63
     */
64
    public function uninstall(Composer $composer, IOInterface $io)
0 ignored issues
show
Unused Code introduced by
The parameter $io is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
    public function uninstall(Composer $composer, /** @scrutinizer ignore-unused */ IOInterface $io)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $composer is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
    public function uninstall(/** @scrutinizer ignore-unused */ Composer $composer, IOInterface $io)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
    {
66
    }
67
68
    /**
69
     * Add installers.
70
     *
71
     * @param InstallerInterface[] ...$installers
72
     *
73
     * @return void
74
     */
75 1
    public function addInstallers(InstallerInterface ...$installers)
76
    {
77 1
        $this->installers = array_merge($this->installers, $installers);
78 1
    }
79
80
    /**
81
     * Run the installers.
82
     *
83
     * @return void
84
     */
85 1
    public function install()
86
    {
87 1
        foreach ($this->installers as $installer) {
88 1
            $installer->install();
89
        }
90 1
    }
91
92
    /**
93
     * Subscribe to post update and post install command.
94
     *
95
     * @return array
96
     */
97 1
    public static function getSubscribedEvents(): array
98
    {
99
        return [
100 1
            'post-install-cmd' => [
101
                'install'
102
            ],
103
            'post-update-cmd' => [
104
                'install'
105
            ]
106
        ];
107
    }
108
}
109