Completed
Push — master ( a14ad6...d9a953 )
by Julián
12:30
created

AbstractCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A reconstitute() 0 4 1
A getAllowedInterfaces() 0 4 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 immutable serializable command.
21
 */
22
abstract class AbstractCommand implements Command
23
{
24
    use ImmutabilityBehaviour, ScalarPayloadBehaviour {
25
        ScalarPayloadBehaviour::__call insteadof ImmutabilityBehaviour;
26
    }
27
28
    /**
29
     * AbstractCommand constructor.
30
     *
31
     * @param mixed[] $parameters
32
     */
33
    final protected function __construct(array $parameters)
34
    {
35
        $this->checkImmutability();
36
37
        $this->setPayload($parameters);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    final public static function reconstitute(array $parameters)
44
    {
45
        return new static($parameters);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     *
51
     * @return string[]
52
     */
53
    final protected function getAllowedInterfaces(): array
54
    {
55
        return [Command::class];
56
    }
57
}
58