Test Failed
Push — master ( 1565e2...1c0683 )
by
unknown
03:24
created

Command   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 70.59%

Importance

Changes 0
Metric Value
wmc 9
eloc 22
dl 0
loc 74
ccs 12
cts 17
cp 0.7059
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassNameCommand() 0 3 1
A getDiretorio() 0 3 1
A create() 0 7 1
A getName() 0 3 1
A __construct() 0 4 1
A getLocalFileCommand() 0 6 1
A getModule() 0 3 1
A getClassNameCommandHandler() 0 3 1
A getLocalFileCommandHandler() 0 6 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: thales
5
 * Date: 14/01/2019
6
 * Time: 19:15
7
 */
8
9
namespace Saci\Console\Domain\Entity;
10
11
12
use Saci\Console\Infrastructure\Application\SymfonyEventAdapter;
13
use Saci\Console\Infrastructure\Domain\Events\CommandWasCreated;
14
15
class Command
16
{
17
    /** @var string */
18
    private $name;
19
    /**
20
     * @var Module
21
     */
22
    private $module;
23
24 5
    public function __construct(string $name, Module $module)
25
    {
26 5
        $this->name = $name;
27 5
        $this->module = $module;
28 5
    }
29
30
    /**
31
     * @param string $name
32
     * @param Module $module
33
     * @return Command
34
     */
35
    public static function create(string $name, Module $module): Command
36
    {
37
        $command = new self($name, $module);
38
        SymfonyEventAdapter::getInstance()->publish(
39
            new CommandWasCreated($command)
40
        );
41
        return $command;
42
    }
43
44
    /**
45
     * @return string
46
     */
47 3
    public function getName(): string
48
    {
49 3
        return $this->name;
50
    }
51
52
    /**
53
     * @return string
54
     */
55 1
    public function getDiretorio(): string
56
    {
57 1
        return $this->module->getDiretorio();
58
    }
59
60 1
    public function getClassNameCommand()
61
    {
62 1
        return ucfirst(strtolower($this->getName())) . 'Command';
63
    }
64
65 1
    public function getLocalFileCommand(): string
66
    {
67 1
        return $this->getDiretorio()
68
            . DIRECTORY_SEPARATOR
69
            . $this->getClassNameCommand()
70
            . '.php';
71
    }
72
73
    public function getClassNameCommandHandler()
74
    {
75
        return ucfirst(strtolower($this->getName())) . 'CommandHandler';
76
    }
77
78
    public function getModule(): Module
79
    {
80
        return $this->module;
81
    }
82
83
    public function getLocalFileCommandHandler()
84
    {
85
        return $this->getDiretorio()
86
            . DIRECTORY_SEPARATOR
87
            . $this->getClassNameCommandHandler()
88
            . '.php';
89
    }
90
}