AbstractEmptyQuery::getAllowedInterfaces()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
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\CQRS\Exception\QueryException;
17
use Gears\DTO\ScalarPayloadBehaviour;
18
use Gears\Immutability\ImmutabilityBehaviour;
19
20
/**
21
 * Abstract empty immutable query.
22
 */
23
abstract class AbstractEmptyQuery implements Query
24
{
25
    use ImmutabilityBehaviour, ScalarPayloadBehaviour {
26
        ScalarPayloadBehaviour::__call insteadof ImmutabilityBehaviour;
27
    }
28
29
    /**
30
     * AbstractEmptyQuery constructor.
31
     */
32
    final protected function __construct()
33
    {
34
        $this->assertImmutable();
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getQueryType(): string
41
    {
42
        return static::class;
43
    }
44
45
    /**
46
     * @return array<string, mixed>
47
     */
48
    final public function __serialize(): array
49
    {
50
        throw new QueryException(\sprintf('Query "%s" cannot be serialized.', static::class));
51
    }
52
53
    /**
54
     * @param array<string, mixed> $data
55
     *
56
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
57
     */
58
    final public function __unserialize(array $data): void
59
    {
60
        throw new QueryException(\sprintf('Query "%s" cannot be unserialized.', static::class));
61
    }
62
63
    /**
64
     * @return string[]
65
     */
66
    final public function __sleep(): array
67
    {
68
        throw new QueryException(\sprintf('Query "%s" cannot be serialized.', static::class));
69
    }
70
71
    final public function __wakeup(): void
72
    {
73
        throw new QueryException(\sprintf('Query "%s" cannot be unserialized.', static::class));
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     *
79
     * @return string[]
80
     */
81
    final protected function getAllowedInterfaces(): array
82
    {
83
        return [Query::class];
84
    }
85
}
86