Passed
Push — master ( 0ccca8...99b735 )
by Alexander
24:50 queued 09:50
created

ComposerEventHandler::onPostAutoloadDump()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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 Plugin $plugin;
17
18
    /**
19
     * Returns list of events the plugin is subscribed to.
20
     *
21
     * @return array list of events
22
     */
23
    public static function getSubscribedEvents(): array
24
    {
25
        return [
26
            ScriptEvents::POST_AUTOLOAD_DUMP => [
27
                ['onPostAutoloadDump', 0],
28
            ],
29
        ];
30
    }
31
32
    public function activate(Composer $composer, IOInterface $io): void
33
    {
34
        $this->plugin = new Plugin($composer, $io);
35
    }
36
37
    public function onPostAutoloadDump(Event $event): void
38
    {
39
        require_once $event->getComposer()->getConfig()->get('vendor-dir') . '/autoload.php';
40
41
        $this->plugin->build();
42
    }
43
44
    public function deactivate(Composer $composer, IOInterface $io)
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

44
    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...
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

44
    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...
45
    {
46
        // do nothing
47
    }
48
49
    public function uninstall(Composer $composer, IOInterface $io)
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

49
    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...
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

49
    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...
50
    {
51
        // do nothing
52
    }
53
}
54