Lines 83.33% 5 / 6
Methods 66.66% 2 / 3
Classes 0.00% 0 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 handledMessageClass 100.00% 1 / 1 100.00% 1 / 1 1
 handle 75.00% 3 / 4 0.00% 0 / 1 2.06
15final readonly class HaConnectionLostHandler implements BrokerMessageHandler
16{
17    public function __construct(
18        private ConnectionStatus $connection,
19        private LocalDispatcher $dispatcher,
20        private LoggerInterface $logger,
21    ) {}
22
23    public function handledMessageClass(): string
24    {
25        return HaConnectionLost::class;
26    }
27
28    /** @param HaConnectionLost $message */
29    public function handle(BrokerMessage $message): void
30    {
31        if (!$this->connection->markLost()) {
32            return;
33        }
34
35        $this->logger->warning('Lost Home Assistant; state reads are stale until it is back', ['reason' => $message->reason]);
36        $this->dispatcher->dispatchConnection(new ConnectionLost($message->lostAt, $message->reason));
37    }
38}