ModuleInstallerPlugin::activate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleSAML\Composer;
4
5
use Composer\Composer;
6
use Composer\IO\IOInterface;
7
use Composer\Plugin\PluginInterface;
8
9
use function file_exists;
10
use function sprintf;
11
12
class ModuleInstallerPlugin implements PluginInterface
13
{
14
    /** @var \SimpleSAML\Composer\ModuleInstaller */
15
    private ModuleInstaller $installer;
16
17
    /** @var \Composer\IO\IOInterface */
18
    private IOInterface $io;
19
20
21
    /**
22
     * Apply plugin modifications to Composer
23
     *
24
     * @param \Composer\Composer $composer
25
     * @param \Composer\IO\IOInterface $io
26
     */
27
    public function activate(Composer $composer, IOInterface $io)
28
    {
29
        $this->io = $io;
30
        $this->installer = new ModuleInstaller($io, $composer);
31
        $composer->getInstallationManager()->addInstaller($this->installer);
32
    }
33
34
35
    /**
36
     * Remove any hooks from Composer
37
     *
38
     * This will be called when a plugin is deactivated before being
39
     * uninstalled, but also before it gets upgraded to a new version
40
     * so the old one can be deactivated and the new one activated.
41
     *
42
     * @param \Composer\Composer $composer
43
     * @param \Composer\IO\IOInterface $io
44
     */
45
    public function deactivate(Composer $composer, IOInterface $io)
46
    {
47
        // Not implemented
48
    }
49
50
51
    /**
52
     * Prepare the plugin to be uninstalled
53
     *
54
     * This will be called after deactivate.
55
     *
56
     * @param \Composer\Composer $composer
57
     * @param \Composer\IO\IOInterface $io
58
     */
59
    public function uninstall(Composer $composer, IOInterface $io)
60
    {
61
        // Not implemented
62
    }
63
}
64