| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | /** |
| 6: | * This file is part of the Nexus MCP SDK package. |
| 7: | * |
| 8: | * (c) 2025 John Paul E. Balandan, CPA <paulbalandan@gmail.com> |
| 9: | * |
| 10: | * For the full copyright and license information, please view |
| 11: | * the LICENSE file that was distributed with this source code. |
| 12: | */ |
| 13: | |
| 14: | namespace Nexus\Mcp\Schema\Sampling; |
| 15: | |
| 16: | use Nexus\Mcp\Schema\Arrayable; |
| 17: | |
| 18: | /** |
| 19: | * Hints to use for model selection. |
| 20: | * |
| 21: | * Keys not declared here are currently left unspecified by the spec and are up to the client to interpret. |
| 22: | * |
| 23: | * @implements Arrayable<array{name?: non-empty-string}> |
| 24: | */ |
| 25: | final readonly class ModelHint implements \JsonSerializable, Arrayable |
| 26: | { |
| 27: | /** |
| 28: | * @param null|non-empty-string $name A hint for a model name. |
| 29: | */ |
| 30: | public function __construct( |
| 31: | public ?string $name = null, |
| 32: | ) {} |
| 33: | |
| 34: | #[\Override] |
| 35: | public function toArray(): array |
| 36: | { |
| 37: | return array_filter([ |
| 38: | 'name' => $this->name, |
| 39: | ], static fn(mixed $value) => null !== $value); |
| 40: | } |
| 41: | |
| 42: | /** |
| 43: | * @return template-type<self, Arrayable, 'T'> |
| 44: | */ |
| 45: | #[\Override] |
| 46: | public function jsonSerialize(): array |
| 47: | { |
| 48: | return $this->toArray(); |
| 49: | } |
| 50: | } |
| 51: |