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

AbstractEmptyCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
dl 0
loc 42
rs 10
c 1
b 0
f 1
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getCommandType() 0 3 1
A getAllowedInterfaces() 0 3 1
A reconstitute() 0 5 1
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