| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Schema\Prompt; |
| 15: | |
| 16: | use Nexus\Mcp\Schema\Arrayable; |
| 17: | use Nexus\Mcp\Schema\BaseMetadata; |
| 18: | use Nexus\Mcp\Schema\Icon; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | final readonly class Prompt extends BaseMetadata |
| 33: | { |
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | public function __construct( |
| 42: | string $name, |
| 43: | ?string $title = null, |
| 44: | public ?string $description = null, |
| 45: | public ?array $arguments = null, |
| 46: | public ?array $icons = null, |
| 47: | public ?array $meta = null, |
| 48: | ) { |
| 49: | parent::__construct($name, $title); |
| 50: | } |
| 51: | |
| 52: | #[\Override] |
| 53: | public function toArray(): array |
| 54: | { |
| 55: | return array_filter([ |
| 56: | '_meta' => $this->meta, |
| 57: | 'name' => $this->name, |
| 58: | 'title' => $this->title, |
| 59: | 'description' => $this->description, |
| 60: | 'arguments' => null === $this->arguments ? null : array_map( |
| 61: | static fn(PromptArgument $arg): array => $arg->toArray(), |
| 62: | $this->arguments, |
| 63: | ), |
| 64: | 'icons' => null === $this->icons ? null : array_map( |
| 65: | static fn(Icon $icon): array => $icon->toArray(), |
| 66: | $this->icons, |
| 67: | ), |
| 68: | ], static fn(mixed $value): bool => null !== $value); |
| 69: | } |
| 70: | } |
| 71: | |