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
StateUpdateBatchHandler 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
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Worker\Message;
6
7use Stewart\Runtime\Dispatch\LocalDispatcher;
8use Stewart\Runtime\Ipc\Message\BrokerMessage;
9use Stewart\Runtime\Ipc\Message\StateUpdateBatch;
10use Stewart\Runtime\Worker\StateCacheSync;
11
12/** @implements BrokerMessageHandler<StateUpdateBatch> */
13final readonly class StateUpdateBatchHandler implements BrokerMessageHandler
14{
15    public function __construct(
16        private StateCacheSync $stateCacheSync,
17        private LocalDispatcher $dispatcher,
18    ) {}
19
20    public function handledMessageClass(): string
21    {
22        return StateUpdateBatch::class;
23    }
24
25    /** @param StateUpdateBatch $message */
26    public function handle(BrokerMessage $message): void
27    {
28        $this->dispatcher->dispatchStateChanges($this->stateCacheSync->applyStateUpdates($message->updates->collection));
29    }
30}