Lines 100.00% 4 / 4
Functions and Methods 100.00% 3 / 3
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
PongHandler 100.00% 4 / 4 100.00% 3 / 3 3 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 handledMessageClass 100.00% 1 / 1 100.00% 1 / 1 1
 handle 100.00% 2 / 2 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Broker\Message;
6
7use Stewart\Runtime\Broker\AppMetrics;
8use Stewart\Runtime\Broker\WorkerHandle;
9use Stewart\Runtime\Broker\WorkerWatchdog;
10use Stewart\Runtime\Ipc\Message\Pong;
11use Stewart\Runtime\Ipc\Message\WorkerMessage;
12
13/** @implements WorkerMessageHandler<Pong> */
14final readonly class PongHandler implements WorkerMessageHandler
15{
16    public function __construct(
17        private WorkerWatchdog $watchdog,
18        private AppMetrics $metrics,
19    ) {}
20
21    public function handledMessageClass(): string
22    {
23        return Pong::class;
24    }
25
26    /** @param Pong $message */
27    public function handle(WorkerHandle $handle, WorkerMessage $message): void
28    {
29        $this->watchdog->recordPong($handle, $message);
30        $this->metrics->recordActivityReports($handle, $message);
31    }
32}