ClassCommandMakerSubscriber   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 3 1
A create() 0 14 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: thales
5
 * Date: 17/01/2019
6
 * Time: 20:18
7
 */
8
9
namespace Saci\Console\Infrastructure\Domain\Services;
10
11
12
use Saci\Console\Domain\Events\CommandWasCreated;
13
use Saci\Console\Infrastructure\Domain\Services\PhpClass\Command;
14
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15
use Symfony\Component\Filesystem\Filesystem;
16
17
class ClassCommandMakerSubscriber implements \Saci\Console\Domain\Services\ClassCommandMakerSubscriber, EventSubscriberInterface
18
{
19
20 2
    public function create(CommandWasCreated $commandWasCreated)
21
    {
22 2
        $classMaker = new CommandClassMaker($commandWasCreated->getCommand());
23 2
        $generateable = $classMaker->generate(new Command());
24 2
        $stringClass = GeneratorClassFactory::create()->generate($generateable);
25
26 2
        $stringClass = "<?php\n" . $stringClass;
27
28 2
        (new Filesystem())->dumpFile(
29 2
            $commandWasCreated->getCommand()->getLocalFileCommand(),
30 2
            $stringClass
31
        );
32
33 2
        return true;
34
    }
35
36 2
    public static function getSubscribedEvents()
37
    {
38 2
        return [CommandWasCreated::NAME => 'create'];
39
    }
40
}