| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Schema\Task; |
| 15: | |
| 16: | use Nexus\Assert\Assert; |
| 17: | use Nexus\Mcp\Core\Schema\Arrayable; |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | final readonly class RelatedTaskMetadata implements Arrayable |
| 28: | { |
| 29: | |
| 30: | |
| 31: | |
| 32: | public string $taskId; |
| 33: | |
| 34: | public function __construct(string $taskId) |
| 35: | { |
| 36: | Assert::that($taskId)->isNonEmptyString('related task metadata "taskId" must be a non-empty string.'); |
| 37: | |
| 38: | $this->taskId = $taskId; |
| 39: | } |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | #[\Override] |
| 45: | public static function fromArray(array $data): static |
| 46: | { |
| 47: | Assert::that($data)->hasOffset('taskId', 'related task metadata missing the required "taskId" key.'); |
| 48: | $taskId = $data['taskId']; |
| 49: | Assert::that($taskId)->isString('related task metadata "taskId" must be a string, {type} given.'); |
| 50: | |
| 51: | return new self($taskId); |
| 52: | } |
| 53: | |
| 54: | #[\Override] |
| 55: | public function toArray(): array |
| 56: | { |
| 57: | return ['taskId' => $this->taskId]; |
| 58: | } |
| 59: | |
| 60: | #[\Override] |
| 61: | public function jsonSerialize(): array |
| 62: | { |
| 63: | return $this->toArray(); |
| 64: | } |
| 65: | } |
| 66: | |