| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Schema\RequestParams; |
| 15: | |
| 16: | use Nexus\Mcp\Core\Schema\RequestMetaObject; |
| 17: | use Nexus\Mcp\Core\Schema\RequestParams; |
| 18: | use Nexus\Mcp\Core\Schema\Task\TaskMetadata; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | abstract readonly class TaskAugmentedRequestParams extends RequestParams |
| 26: | { |
| 27: | public function __construct(public ?TaskMetadata $task = null, RequestMetaObject $meta = new RequestMetaObject()) |
| 28: | { |
| 29: | parent::__construct($meta); |
| 30: | } |
| 31: | |
| 32: | #[\Override] |
| 33: | public function toArray(): array |
| 34: | { |
| 35: | $data = parent::toArray(); |
| 36: | |
| 37: | if (null !== $this->task) { |
| 38: | $task = $this->task->toArray(); |
| 39: | |
| 40: | if ([] !== $task) { |
| 41: | $data['task'] = $task; |
| 42: | } |
| 43: | } |
| 44: | |
| 45: | return $data; |
| 46: | } |
| 47: | |
| 48: | #[\Override] |
| 49: | public function jsonSerialize(): array |
| 50: | { |
| 51: | return $this->toArray(); |
| 52: | } |
| 53: | } |
| 54: | |