1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* cqrs-async (https://github.com/phpgears/cqrs-async). |
5
|
|
|
* Async decorator for CQRS command bus. |
6
|
|
|
* |
7
|
|
|
* @license MIT |
8
|
|
|
* @link https://github.com/phpgears/cqrs-async |
9
|
|
|
* @author Julián Gutiérrez <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types=1); |
13
|
|
|
|
14
|
|
|
namespace Gears\CQRS\Async; |
15
|
|
|
|
16
|
|
|
use Gears\CQRS\Async\Exception\ReceivedCommandException; |
17
|
|
|
use Gears\CQRS\Command; |
18
|
|
|
|
19
|
|
|
final class ReceivedCommand implements Command |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Command |
23
|
|
|
*/ |
24
|
|
|
private $originalCommand; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* ReceivedCommand constructor. |
28
|
|
|
* |
29
|
|
|
* @param Command $originalCommand |
30
|
|
|
*/ |
31
|
|
|
public function __construct(Command $originalCommand) |
32
|
|
|
{ |
33
|
|
|
$this->originalCommand = $originalCommand; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Get original command. |
38
|
|
|
* |
39
|
|
|
* @return Command |
40
|
|
|
*/ |
41
|
|
|
public function getOriginalCommand(): Command |
42
|
|
|
{ |
43
|
|
|
return $this->originalCommand; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
* |
49
|
|
|
* @throws ReceivedCommandException |
50
|
|
|
*/ |
51
|
|
|
public function getCommandType(): string |
52
|
|
|
{ |
53
|
|
|
throw new ReceivedCommandException(\sprintf('Method %s should not be called ', __METHOD__)); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
* |
59
|
|
|
* @throws ReceivedCommandException |
60
|
|
|
*/ |
61
|
|
|
public function has(string $parameter): bool |
62
|
|
|
{ |
63
|
|
|
throw new ReceivedCommandException(\sprintf('Method %s should not be called ', __METHOD__)); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* {@inheritdoc} |
68
|
|
|
* |
69
|
|
|
* @throws ReceivedCommandException |
70
|
|
|
* |
71
|
|
|
* @return mixed |
72
|
|
|
*/ |
73
|
|
|
public function get(string $parameter) |
74
|
|
|
{ |
75
|
|
|
throw new ReceivedCommandException(\sprintf('Method %s should not be called ', __METHOD__)); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* {@inheritdoc} |
80
|
|
|
* |
81
|
|
|
* @throws ReceivedCommandException |
82
|
|
|
* |
83
|
|
|
* @return array<string, mixed> |
84
|
|
|
*/ |
85
|
|
|
public function getPayload(): array |
86
|
|
|
{ |
87
|
|
|
throw new ReceivedCommandException(\sprintf('Method %s should not be called ', __METHOD__)); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* {@inheritdoc} |
92
|
|
|
* |
93
|
|
|
* @throws ReceivedCommandException |
94
|
|
|
*/ |
95
|
|
|
public static function reconstitute(array $parameters): void |
96
|
|
|
{ |
97
|
|
|
throw new ReceivedCommandException(\sprintf('Method %s should not be called ', __METHOD__)); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|