mode = self::MODE; $this->message = $message; $this->elicitationId = $elicitationId; $this->url = $url; } /** * Creates an instance from an array. * * @param array{ * task?: array|\WP\McpSchema\Client\Tasks\DTO\TaskMetadata|null, * _meta?: array|\WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null, * mode: 'url', * message: string, * elicitationId: string, * url: string * } $data * @phpstan-param array $data * @return self */ public static function fromArray(array $data): self { self::assertRequired($data, ['message', 'elicitationId', 'url']); /** @var \WP\McpSchema\Client\Tasks\DTO\TaskMetadata|null $task */ $task = isset($data['task']) ? (is_array($data['task']) ? TaskMetadata::fromArray(self::asArray($data['task'])) : $data['task']) : null; /** @var \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta */ $_meta = isset($data['_meta']) ? (is_array($data['_meta']) ? RequestParamsMeta::fromArray(self::asArray($data['_meta'])) : $data['_meta']) : null; return new self( self::asString($data['message']), self::asString($data['elicitationId']), self::asString($data['url']), $task, $_meta ); } /** * Converts the instance to an array. * * @return array */ public function toArray(): array { $result = parent::toArray(); $result['mode'] = $this->mode; $result['message'] = $this->message; $result['elicitationId'] = $this->elicitationId; $result['url'] = $this->url; return $result; } /** * @return 'url' */ public function getMode(): string { return $this->mode; } /** * @return string */ public function getMessage(): string { return $this->message; } /** * @return string */ public function getElicitationId(): string { return $this->elicitationId; } /** * @return string */ public function getUrl(): string { return $this->url; } }