1 | <?php |
||
16 | final class CommandLogger implements Countable, CommandSubscriber |
||
17 | { |
||
18 | /** @var Command[] */ |
||
19 | private $commands = []; |
||
20 | |||
21 | /** @var CommandStartedEvent[] */ |
||
22 | private $startedCommands = []; |
||
23 | |||
24 | /** @var bool */ |
||
25 | private $registered = false; |
||
26 | |||
27 | 28 | public function register(): void |
|
36 | |||
37 | 28 | public function unregister(): void |
|
46 | |||
47 | 28 | public function commandStarted(CommandStartedEvent $event) |
|
51 | |||
52 | 28 | public function commandSucceeded(CommandSucceededEvent $event) |
|
61 | |||
62 | public function commandFailed(CommandFailedEvent $event) |
||
71 | |||
72 | 13 | public function clear(): void |
|
76 | |||
77 | 15 | public function count(): int |
|
81 | |||
82 | /** |
||
83 | * @return Command[] |
||
84 | */ |
||
85 | 4 | public function getAll(): array |
|
89 | |||
90 | 28 | private function findAndRemoveCommandStartedEvent(string $requestId): ?CommandStartedEvent |
|
91 | { |
||
92 | 28 | $startedEvent = $this->startedCommands[$requestId] ?? null; |
|
93 | 28 | unset($this->startedCommands[$requestId]); |
|
94 | |||
95 | 28 | return $startedEvent; |
|
96 | } |
||
97 | |||
98 | 28 | private function logCommand(Command $command): void |
|
102 | } |
||
103 |