| 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\Arrayable; |
| 18: | use Nexus\Mcp\Core\Schema\RequestMetaObject; |
| 19: | use Nexus\Mcp\Core\Schema\RequestParams; |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | final readonly class EmptyRequestParams extends RequestParams |
| 31: | { |
| 32: | public function __construct(RequestMetaObject $meta) |
| 33: | { |
| 34: | parent::__construct(meta: $meta); |
| 35: | } |
| 36: | |
| 37: | #[\Override] |
| 38: | public static function fromArray(array $data): static |
| 39: | { |
| 40: | Assert::that($data)->hasOffset('_meta', '"params" is missing the required "_meta" key.'); |
| 41: | Assert::that($data['_meta']) |
| 42: | ->isArray('"params._meta" must be an object, {type} given.') |
| 43: | ->isMap('"params._meta" must be a string-keyed object.') |
| 44: | ; |
| 45: | $meta = RequestMetaObject::fromArray($data['_meta']); |
| 46: | |
| 47: | return new self(meta: $meta); |
| 48: | } |
| 49: | |
| 50: | #[\Override] |
| 51: | public function toArray(): array |
| 52: | { |
| 53: | return ['_meta' => $this->meta->toArray()]; |
| 54: | } |
| 55: | } |
| 56: | |