Test Failed
Push — master ( 4bd70e...3667db )
by Grupo
04:16
created

ModuleMakerSubscriber::createModule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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
    public static function getSubscribedEvents()
38
    {
39
        return [ModuleWasCreated::NAME => 'createModule'];
40
    }
41
42
    /**
43
     * @param ModuleWasCreated $created
44
     * @throws \Saci\Console\Domain\Exceptions\ModuleAlreadyExists
45
     */
46
    public function createModule(ModuleWasCreated $created)
47
    {
48
        ModuleMakerFactory::create()->make($created->getModule());
49
    }
50
}