Passed
Push — master ( 53b3d3...a35a46 )
by Julián
06:01 queued 13s
created

AbstractEmptyCommand::getCommandType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * cqrs (https://github.com/phpgears/cqrs).
5
 * CQRS base.
6
 *
7
 * @license MIT
8
 * @link https://github.com/phpgears/cqrs
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
declare(strict_types=1);
13
14
namespace Gears\CQRS;
15
16
use Gears\DTO\ScalarPayloadBehaviour;
17
use Gears\Immutability\ImmutabilityBehaviour;
18
19
/**
20
 * Abstract empty immutable serializable command.
21
 */
22
abstract class AbstractEmptyCommand implements Command
23
{
24
    use ImmutabilityBehaviour, ScalarPayloadBehaviour {
25
        ScalarPayloadBehaviour::__call insteadof ImmutabilityBehaviour;
26
    }
27
28
    /**
29
     * AbstractEmptyCommand constructor.
30
     */
31
    final protected function __construct()
32
    {
33
        $this->assertImmutable();
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getCommandType(): string
40
    {
41
        return \get_called_class();
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     *
47
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
48
     */
49
    final public static function reconstitute(array $parameters)
50
    {
51
        $commandClass = \get_called_class();
52
53
        return new $commandClass();
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     *
59
     * @return string[]
60
     */
61
    final protected function getAllowedInterfaces(): array
62
    {
63
        return [Command::class];
64
    }
65
}
66