| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Schema\Elicitation; |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | final readonly class StringSchema implements PrimitiveSchemaDefinition |
| 28: | { |
| 29: | |
| 30: | |
| 31: | |
| 32: | public string $type; |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | public function __construct( |
| 42: | public ?string $description = null, |
| 43: | public ?string $title = null, |
| 44: | public ?int $minLength = null, |
| 45: | public ?int $maxLength = null, |
| 46: | public ?string $format = null, |
| 47: | public ?string $default = null, |
| 48: | ) { |
| 49: | $this->type = 'string'; |
| 50: | } |
| 51: | |
| 52: | #[\Override] |
| 53: | public function toArray(): array |
| 54: | { |
| 55: | return array_filter([ |
| 56: | 'type' => $this->type, |
| 57: | 'description' => $this->description, |
| 58: | 'title' => $this->title, |
| 59: | 'minLength' => $this->minLength, |
| 60: | 'maxLength' => $this->maxLength, |
| 61: | 'format' => $this->format, |
| 62: | 'default' => $this->default, |
| 63: | ], static fn(mixed $value): bool => null !== $value); |
| 64: | } |
| 65: | |
| 66: | |
| 67: | |
| 68: | |
| 69: | #[\Override] |
| 70: | public function jsonSerialize(): array |
| 71: | { |
| 72: | return $this->toArray(); |
| 73: | } |
| 74: | } |
| 75: | |