1 | <?php |
||
33 | class RecordingCommandBus implements CommandBusInterface |
||
34 | { |
||
35 | /** |
||
36 | * @var array |
||
37 | */ |
||
38 | private $subscriptions; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | private $dispatchedCommands = []; |
||
44 | |||
45 | /** |
||
46 | * @var CallbackBehaviorInterface |
||
47 | */ |
||
48 | private $callbackBehavior; |
||
49 | |||
50 | 5 | function __construct() |
|
55 | |||
56 | |||
57 | public function dispatch( |
||
73 | |||
74 | /** |
||
75 | * {@inheritdoc} |
||
76 | */ |
||
77 | public function subscribe($commandName, CommandHandlerInterface $handler) |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public function unsubscribe($commandName, CommandHandlerInterface $handler) |
||
93 | |||
94 | /** |
||
95 | * Clears all the commands recorded by this Command Bus. |
||
96 | */ |
||
97 | 5 | public function clearCommands() |
|
101 | |||
102 | /** |
||
103 | * Clears all subscribed handlers on this command bus. |
||
104 | */ |
||
105 | public function clearSubscriptions() |
||
109 | |||
110 | /** |
||
111 | * Indicates whether the given <code>commandHandler</code> is subscribed to this command bus. |
||
112 | * |
||
113 | * @param CommandHandlerInterface $commandHandler The command handler to verify the subscription for |
||
114 | * @return boolean <code>true</code> if the handler is subscribed, otherwise <code>false</code>. |
||
115 | */ |
||
116 | public function isSubscribed(CommandHandlerInterface $commandHandler) |
||
126 | |||
127 | |||
128 | /** |
||
129 | * Returns a Map will all Command Names and their Command Handler that have been subscribed to this command bus. |
||
130 | * |
||
131 | * @return array a Map will all Command Names and their Command Handler |
||
132 | */ |
||
133 | public function getSubscriptions() |
||
137 | |||
138 | /** |
||
139 | * Returns a list with all commands that have been dispatched by this command bus. |
||
140 | * |
||
141 | * @return array a list with all commands that have been dispatched |
||
142 | */ |
||
143 | 3 | public function getDispatchedCommands() |
|
147 | |||
148 | |||
149 | /** |
||
150 | * Sets the instance that defines the behavior of the Command Bus when a command is dispatched with a callback. |
||
151 | * |
||
152 | * @param CallbackBehaviorInterface $callbackBehavior The instance deciding to how the callback should be invoked. |
||
153 | */ |
||
154 | public function setCallbackBehavior(CallbackBehaviorInterface $callbackBehavior) |
||
158 | |||
159 | |||
160 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.