Lines
0.00%
0 / 3
Functions and Methods
0.00%
0 / 3
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| PingHandler | 0.00% | 0 / 3 | 0.00% | 0 / 3 | 12 | 0.00% | 0 / 1 | |||
| __construct | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| handledMessageClass | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| handle | 0.00% | 0 / 1 | 0.00% | 0 / 1 | 2 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | declare(strict_types=1); | |
| 4 | ||
| 5 | namespace Stewart\Runtime\Worker\Message; | |
| 6 | ||
| 7 | use Stewart\Runtime\Ipc\Message\BrokerMessage; | |
| 8 | use Stewart\Runtime\Ipc\Message\Ping; | |
| 9 | use Stewart\Runtime\Ipc\Transport; | |
| 10 | use Stewart\Runtime\Worker\PongBuilder; | |
| 11 | ||
| 12 | /** @implements BrokerMessageHandler<Ping> */ | |
| 13 | final readonly class PingHandler implements BrokerMessageHandler | |
| 14 | { | |
| 15 | public function __construct( | |
| 16 | private Transport $transport, | |
| 17 | private PongBuilder $pongBuilder, | |
| 18 | ) {} | |
| 19 | ||
| 20 | public function handledMessageClass(): string | |
| 21 | { | |
| 22 | return Ping::class; | |
| 23 | } | |
| 24 | ||
| 25 | /** @param Ping $message */ | |
| 26 | public function handle(BrokerMessage $message): void | |
| 27 | { | |
| 28 | $this->transport->send($this->pongBuilder->buildPongFor($message)); | |
| 29 | } | |
| 30 | } |