1: | <?php |
2: | |
3: | declare(strict_types=1); |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | namespace Nexus\Mcp\Message; |
15: | |
16: | |
17: | |
18: | |
19: | final readonly class JsonRpcRequest extends Request |
20: | { |
21: | |
22: | |
23: | |
24: | |
25: | |
26: | public function __construct( |
27: | string $jsonrpc, |
28: | public RequestId $requestId, |
29: | string $method, |
30: | ?array $params = null, |
31: | ) { |
32: | parent::__construct($jsonrpc, $method, $params); |
33: | } |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | |
40: | |
41: | |
42: | |
43: | #[\Override] |
44: | public function toArray(): array |
45: | { |
46: | return array_filter([ |
47: | 'jsonrpc' => $this->jsonrpc, |
48: | 'id' => $this->requestId->id, |
49: | 'method' => $this->method, |
50: | 'params' => $this->params, |
51: | ], static fn(mixed $value): bool => null !== $value); |
52: | } |
53: | } |
54: | |