|null */ protected ?array $_meta; /** * @param string $data @since 2024-11-05 * @param string $mimeType @since 2024-11-05 * @param \WP\McpSchema\Common\Protocol\DTO\Annotations|null $annotations @since 2024-11-05 * @param array|null $_meta @since 2025-06-18 */ public function __construct( string $data, string $mimeType, ?Annotations $annotations = null, ?array $_meta = null ) { $this->type = self::TYPE; $this->data = $data; $this->mimeType = $mimeType; $this->annotations = $annotations; $this->_meta = $_meta; } /** * Creates an instance from an array. * * @param array{ * type: 'image', * data: string, * mimeType: string, * annotations?: array|\WP\McpSchema\Common\Protocol\DTO\Annotations|null, * _meta?: array|null * } $data * @phpstan-param array $data * @return self */ public static function fromArray(array $data): self { self::assertRequired($data, ['data', 'mimeType']); /** @var \WP\McpSchema\Common\Protocol\DTO\Annotations|null $annotations */ $annotations = isset($data['annotations']) ? (is_array($data['annotations']) ? Annotations::fromArray(self::asArray($data['annotations'])) : $data['annotations']) : null; return new self( self::asString($data['data']), self::asString($data['mimeType']), $annotations, self::asArrayOrNull($data['_meta'] ?? null) ); } /** * Converts the instance to an array. * * @return array */ public function toArray(): array { $result = []; $result['type'] = $this->type; $result['data'] = $this->data; $result['mimeType'] = $this->mimeType; if ($this->annotations !== null) { $result['annotations'] = $this->annotations->toArray(); } if ($this->_meta !== null) { $result['_meta'] = $this->_meta; } return $result; } /** * @return 'image' */ public function getType(): string { return $this->type; } /** * @return string */ public function getData(): string { return $this->data; } /** * @return string */ public function getMimeType(): string { return $this->mimeType; } /** * @return \WP\McpSchema\Common\Protocol\DTO\Annotations|null */ public function getAnnotations(): ?Annotations { return $this->annotations; } /** * @return array|null */ public function get_meta(): ?array { return $this->_meta; } }