Passed
Push — master ( c5b65b...e4c895 )
by Pol
02:27
created

Plugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 32
ccs 6
cts 8
cp 0.75
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 3 1
A regeneration() 0 7 1
A activate() 0 2 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\ComposerPackages;
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
/**
15
 * Class Plugin.
16
 */
17
final class Plugin implements EventSubscriberInterface, PluginInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function activate(Composer $composer, IOInterface $io): void
23
    {
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 1
    public static function getSubscribedEvents(): array
30
    {
31 1
        return [ScriptEvents::POST_AUTOLOAD_DUMP => 'regeneration'];
32
    }
33
34
    /**
35
     * @param \Composer\Script\Event $composerEvent
36
     *
37
     * @throws \ReflectionException
38
     * @throws \Twig\Error\LoaderError
39
     * @throws \Twig\Error\RuntimeError
40
     * @throws \Twig\Error\SyntaxError
41
     */
42 2
    public static function regeneration(Event $composerEvent): void
43
    {
44 2
        $composerEvent->getIO()->write('<info>drupol/composer-packages:</info> Regenerating classes...');
45
46 2
        (new ClassGenerator($composerEvent))->regenerateClasses();
47
48 2
        $composerEvent->getIO()->write('<info>drupol/composer-packages:</info> Done.');
49 2
    }
50
}
51