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