| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Schema\Result; |
| 15: | |
| 16: | use Nexus\Mcp\Schema\Arrayable; |
| 17: | use Nexus\Mcp\Schema\Content\AudioContent; |
| 18: | use Nexus\Mcp\Schema\Content\ImageContent; |
| 19: | use Nexus\Mcp\Schema\Content\TextContent; |
| 20: | use Nexus\Mcp\Schema\Enum\Role; |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | |
| 34: | |
| 35: | final readonly class CreateMessageResult extends Result implements ClientResult |
| 36: | { |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | public function __construct( |
| 42: | public Role $role, |
| 43: | public AudioContent|ImageContent|TextContent $content, |
| 44: | public string $model, |
| 45: | public ?string $stopReason = null, |
| 46: | ?array $meta = null, |
| 47: | ) { |
| 48: | parent::__construct($meta); |
| 49: | } |
| 50: | |
| 51: | #[\Override] |
| 52: | public function toArray(): array |
| 53: | { |
| 54: | return array_filter([ |
| 55: | '_meta' => $this->meta, |
| 56: | 'role' => $this->role->value, |
| 57: | 'content' => $this->content->toArray(), |
| 58: | 'model' => $this->model, |
| 59: | 'stopReason' => $this->stopReason, |
| 60: | ], static fn(mixed $value): bool => null !== $value); |
| 61: | } |
| 62: | } |
| 63: | |