| 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: | final readonly class NumberSchema implements PrimitiveSchemaDefinition |
| 27: | { |
| 28: | |
| 29: | |
| 30: | |
| 31: | public string $type; |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | public function __construct( |
| 38: | public ?string $description = null, |
| 39: | public ?string $title = null, |
| 40: | public null|float|int $minimum = null, |
| 41: | public null|float|int $maximum = null, |
| 42: | public null|float|int $default = null, |
| 43: | ) { |
| 44: | $this->type = 'number'; |
| 45: | } |
| 46: | |
| 47: | #[\Override] |
| 48: | public function toArray(): array |
| 49: | { |
| 50: | return array_filter([ |
| 51: | 'type' => $this->type, |
| 52: | 'description' => $this->description, |
| 53: | 'title' => $this->title, |
| 54: | 'minimum' => $this->minimum, |
| 55: | 'maximum' => $this->maximum, |
| 56: | 'default' => $this->default, |
| 57: | ], static fn(mixed $value): bool => null !== $value); |
| 58: | } |
| 59: | |
| 60: | |
| 61: | |
| 62: | |
| 63: | #[\Override] |
| 64: | public function jsonSerialize(): array |
| 65: | { |
| 66: | return $this->toArray(); |
| 67: | } |
| 68: | } |
| 69: | |