| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Schema; |
| 15: | |
| 16: | use Nexus\Assert\Assert; |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | abstract readonly class BaseMetadata |
| 24: | { |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | public function __construct( |
| 30: | public string $name, |
| 31: | public ?string $title = null, |
| 32: | ) { |
| 33: | $label = basename(strtr(static::class, '\\', '/')); |
| 34: | |
| 35: | Assert::that($name)->isNonEmptyString(\sprintf('%s name must be a non-empty string.', $label)); |
| 36: | Assert::that($title)->nullOr()->isNonEmptyString(\sprintf('%s title must be a non-empty string or null.', $label)); |
| 37: | } |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | public function getDisplayName(): string |
| 45: | { |
| 46: | return $this->title ?? $this->name; |
| 47: | } |
| 48: | } |
| 49: | |