Passed
Pull Request — master (#54)
by Alexander
12:39
created

ComposerEventHandler::deactivate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config;
6
7
use Composer\Composer;
8
use Composer\EventDispatcher\EventSubscriberInterface;
9
use Composer\IO\IOInterface;
10
use Composer\Plugin\PluginInterface;
11
use Composer\Script\Event;
12
use Composer\Script\ScriptEvents;
13
14
final class ComposerEventHandler implements PluginInterface, EventSubscriberInterface
15
{
16
    private Composer $composer;
17
    private IOInterface $io;
18
19
    /**
20
     * Returns list of events the plugin is subscribed to.
21
     *
22
     * @return array list of events
23
     */
24
    public static function getSubscribedEvents(): array
25
    {
26
        return [
27
            ScriptEvents::POST_AUTOLOAD_DUMP => [
28
                ['onPostAutoloadDump', 0],
29
            ],
30
        ];
31
    }
32
33
    public function activate(Composer $composer, IOInterface $io): void
34
    {
35
        $this->composer = $composer;
36
        $this->io = $io;
37
    }
38
39
    public function onPostAutoloadDump(Event $event): void
40
    {
41
        require_once $event->getComposer()->getConfig()->get('vendor-dir') . '/autoload.php';
42
43
        $plugin = new Plugin($this->composer, $this->io);
44
        $plugin->build();
45
    }
46
47
    public function deactivate(Composer $composer, IOInterface $io): void
0 ignored issues
show
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

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

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 $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

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

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...
48
    {
49
        // do nothing
50
    }
51
52
    public function uninstall(Composer $composer, IOInterface $io): void
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 uninstall(Composer $composer, /** @scrutinizer ignore-unused */ IOInterface $io): void

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 uninstall(/** @scrutinizer ignore-unused */ Composer $composer, IOInterface $io): void

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
        // do nothing
55
    }
56
}
57