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

AbstractQuery   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 34
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

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