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