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