Lines 90.00% 9 / 10
Functions and Methods 75.00% 3 / 4
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
SubscribeComponentSession 90.00% 9 / 10 75.00% 3 / 4 4.02 0.00% 0 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 type 0.00% 0 / 1 0.00% 0 / 1 2
 describe 100.00% 1 / 1 100.00% 1 / 1 1
 toMessage 100.00% 7 / 7 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Client\Connection\Command\Component;
6
7use Stewart\Client\Component\ComponentProtocol;
8use Stewart\Client\Component\ComponentSessionRequest;
9use Stewart\Client\Connection\Command\SubscriptionCommand;
10
11final readonly class SubscribeComponentSession implements SubscriptionCommand
12{
13    public function __construct(public ComponentSessionRequest $request) {}
14
15    public function type(): string
16    {
17        return 'stewart/session/subscribe';
18    }
19
20    public function describe(): string
21    {
22        return \sprintf('%s "%s"', $this->type(), $this->request->instance);
23    }
24
25    public function toMessage(): array
26    {
27        return [
28            'type' => $this->type(),
29            'instance' => $this->request->instance->value,
30            'protocol' => ComponentProtocol::VERSION,
31            'stewart_version' => $this->request->stewartVersion,
32            'command_timeout' => $this->request->commandTimeout->toSeconds(),
33        ];
34    }
35}