ModuleMakerSubscriber   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 3
dl 0
loc 33
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 3 1
A createModule() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: thalesmartins
5
 * Date: 11/12/2018
6
 * Time: 12:42
7
 */
8
9
namespace Saci\Console\Infrastructure\Domain\Services;
10
11
12
use Saci\Console\Domain\Events\ModuleWasCreated;
13
use Saci\Console\Domain\Services;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
16
class ModuleMakerSubscriber implements Services\ModuleMakerSubscriber, EventSubscriberInterface
17
{
18
19
    /**
20
     * Returns an array of event names this subscriber wants to listen to.
21
     *
22
     * The array keys are event names and the value can be:
23
     *
24
     *  * The method name to call (priority defaults to 0)
25
     *  * An array composed of the method name to call and the priority
26
     *  * An array of arrays composed of the method names to call and respective
27
     *    priorities, or 0 if unset
28
     *
29
     * For instance:
30
     *
31
     *  * array('eventName' => 'methodName')
32
     *  * array('eventName' => array('methodName', $priority))
33
     *  * array('eventName' => array(array('methodName1', $priority), array('methodName2')))
34
     *
35
     * @return array The event names to listen to
36
     */
37 1
    public static function getSubscribedEvents()
38
    {
39 1
        return [ModuleWasCreated::NAME => 'createModule'];
40
    }
41
42
    /**
43
     * @param ModuleWasCreated $created
44
     * @throws \Saci\Console\Domain\Exceptions\ModuleAlreadyExists
45
     */
46 1
    public function createModule(ModuleWasCreated $created)
47
    {
48 1
        ModuleMakerFactory::create()->make($created->getModule());
49
    }
50
}