convertkit
/
vendor
/
wordpress
/
php-mcp-schema
/
src
/
Server
/
Prompts
/
DTO
/
GetPromptRequestParams.php
GetPromptRequestParams.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at vendor/wordpress/php-mcp-schema/src/Server/Prompts/DTO/GetPromptRequestParams.php
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace WP\McpSchema\Server\Prompts\DTO; |
| 6 | |
| 7 | use WP\McpSchema\Common\JsonRpc\DTO\RequestParams; |
| 8 | use WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta; |
| 9 | use WP\McpSchema\Common\Traits\ValidatesRequiredFields; |
| 10 | |
| 11 | /** |
| 12 | * Parameters for a `prompts/get` request. |
| 13 | * |
| 14 | * @since 2025-11-25 |
| 15 | * |
| 16 | * @mcp-domain Server |
| 17 | * @mcp-subdomain Prompts |
| 18 | * @mcp-version 2025-11-25 |
| 19 | */ |
| 20 | class GetPromptRequestParams extends RequestParams |
| 21 | { |
| 22 | use ValidatesRequiredFields; |
| 23 | |
| 24 | /** |
| 25 | * The name of the prompt or prompt template. |
| 26 | * |
| 27 | * @since 2025-11-25 |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | protected string $name; |
| 32 | |
| 33 | /** |
| 34 | * Arguments to use for templating the prompt. |
| 35 | * |
| 36 | * @since 2025-11-25 |
| 37 | * |
| 38 | * @var array<string, string>|null |
| 39 | */ |
| 40 | protected ?array $arguments; |
| 41 | |
| 42 | /** |
| 43 | * @param string $name @since 2025-11-25 |
| 44 | * @param \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta @since 2025-11-25 |
| 45 | * @param array<string, string>|null $arguments @since 2025-11-25 |
| 46 | */ |
| 47 | public function __construct( |
| 48 | string $name, |
| 49 | ?RequestParamsMeta $_meta = null, |
| 50 | ?array $arguments = null |
| 51 | ) { |
| 52 | parent::__construct($_meta); |
| 53 | $this->name = $name; |
| 54 | $this->arguments = $arguments; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Creates an instance from an array. |
| 59 | * |
| 60 | * @param array{ |
| 61 | * _meta?: array<string, mixed>|\WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null, |
| 62 | * name: string, |
| 63 | * arguments?: array<string, string>|null |
| 64 | * } $data |
| 65 | * @phpstan-param array<string, mixed> $data |
| 66 | * @return self |
| 67 | */ |
| 68 | public static function fromArray(array $data): self |
| 69 | { |
| 70 | self::assertRequired($data, ['name']); |
| 71 | |
| 72 | /** @var \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta */ |
| 73 | $_meta = isset($data['_meta']) |
| 74 | ? (is_array($data['_meta']) |
| 75 | ? RequestParamsMeta::fromArray(self::asArray($data['_meta'])) |
| 76 | : $data['_meta']) |
| 77 | : null; |
| 78 | |
| 79 | return new self( |
| 80 | self::asString($data['name']), |
| 81 | $_meta, |
| 82 | self::asStringMapOrNull($data['arguments'] ?? null) |
| 83 | ); |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Converts the instance to an array. |
| 88 | * |
| 89 | * @return array<string, mixed> |
| 90 | */ |
| 91 | public function toArray(): array |
| 92 | { |
| 93 | $result = parent::toArray(); |
| 94 | |
| 95 | $result['name'] = $this->name; |
| 96 | if ($this->arguments !== null) { |
| 97 | $result['arguments'] = $this->arguments; |
| 98 | } |
| 99 | |
| 100 | return $result; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * @return string |
| 105 | */ |
| 106 | public function getName(): string |
| 107 | { |
| 108 | return $this->name; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * @return array<string, string>|null |
| 113 | */ |
| 114 | public function getArguments(): ?array |
| 115 | { |
| 116 | return $this->arguments; |
| 117 | } |
| 118 | } |
| 119 |