Conditions | 3 |
Paths | 2 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function execute($command, callable $next) |
||
22 | { |
||
23 | if (!$command instanceof ClearActiveCommand) { |
||
24 | return $next($command); |
||
25 | } |
||
26 | |||
27 | if (!$subject = $command->storage) { |
||
28 | throw new \LogicException("Require storage before using this middleware!"); |
||
29 | } |
||
30 | |||
31 | $command->message = new TextTemplate(); |
||
32 | $command->message->text = sprintf('Cancel a command %s', $command->storage->getLineActiveCmd()); |
||
33 | |||
34 | /** @var User $subject */ |
||
35 | $subject->setLineActiveCmd(null); |
||
36 | $subject->setLineCommandData([]); |
||
37 | $subject->setState([User::START_STATE => 1]); |
||
38 | |||
39 | return $next($command); |
||
40 | } |
||
42 |