| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Schema\RequestParams; |
| 15: | |
| 16: | use Nexus\Assert\Assert; |
| 17: | use Nexus\Mcp\Core\Schema\RequestMetaObject; |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | final readonly class SubscribeRequestParams extends ResourceRequestParams |
| 25: | { |
| 26: | |
| 27: | |
| 28: | |
| 29: | #[\Override] |
| 30: | public static function fromArray(array $data): static |
| 31: | { |
| 32: | Assert::that($data)->hasOffset('uri', 'missing the required "uri" key.'); |
| 33: | $uri = $data['uri']; |
| 34: | Assert::that($uri)->isString('"params.uri" must be a string, {type} given.'); |
| 35: | |
| 36: | $meta = new RequestMetaObject(); |
| 37: | |
| 38: | if (\array_key_exists('_meta', $data)) { |
| 39: | Assert::that($data['_meta']) |
| 40: | ->isArray('"params._meta" must be an object, {type} given.') |
| 41: | ->isMap('"params._meta" must be a string-keyed object.') |
| 42: | ; |
| 43: | $meta = RequestMetaObject::fromArray($data['_meta']); |
| 44: | } |
| 45: | |
| 46: | return new self($uri, $meta); |
| 47: | } |
| 48: | } |
| 49: | |