PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
convertkit / vendor / wordpress / php-mcp-schema / src / Server / Prompts / DTO / PromptArgument.php

PromptArgument.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/PromptArgument.php

118 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Server\Prompts\DTO;
6
7 use WP\McpSchema\Common\Protocol\DTO\BaseMetadata;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Describes an argument that a prompt can accept.
12 *
13 * @since 2024-11-05
14 * @last-updated 2025-06-18 (added properties: title)
15 *
16 * @mcp-domain Server
17 * @mcp-subdomain Prompts
18 * @mcp-version 2025-11-25
19 */
20 class PromptArgument extends BaseMetadata
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * A human-readable description of the argument.
26 *
27 * @since 2024-11-05
28 *
29 * @var string|null
30 */
31 protected ?string $description;
32
33 /**
34 * Whether this argument must be provided.
35 *
36 * @since 2024-11-05
37 *
38 * @var bool|null
39 */
40 protected ?bool $required;
41
42 /**
43 * @param string $name @since 2024-11-05
44 * @param string|null $title @since 2025-06-18
45 * @param string|null $description @since 2024-11-05
46 * @param bool|null $required @since 2024-11-05
47 */
48 public function __construct(
49 string $name,
50 ?string $title = null,
51 ?string $description = null,
52 ?bool $required = null
53 ) {
54 parent::__construct($name, $title);
55 $this->description = $description;
56 $this->required = $required;
57 }
58
59 /**
60 * Creates an instance from an array.
61 *
62 * @param array{
63 * name: string,
64 * title?: string|null,
65 * description?: string|null,
66 * required?: bool|null
67 * } $data
68 * @phpstan-param array<string, mixed> $data
69 * @return self
70 */
71 public static function fromArray(array $data): self
72 {
73 self::assertRequired($data, ['name']);
74
75 return new self(
76 self::asString($data['name']),
77 self::asStringOrNull($data['title'] ?? null),
78 self::asStringOrNull($data['description'] ?? null),
79 self::asBoolOrNull($data['required'] ?? null)
80 );
81 }
82
83 /**
84 * Converts the instance to an array.
85 *
86 * @return array<string, mixed>
87 */
88 public function toArray(): array
89 {
90 $result = parent::toArray();
91
92 if ($this->description !== null) {
93 $result['description'] = $this->description;
94 }
95 if ($this->required !== null) {
96 $result['required'] = $this->required;
97 }
98
99 return $result;
100 }
101
102 /**
103 * @return string|null
104 */
105 public function getDescription(): ?string
106 {
107 return $this->description;
108 }
109
110 /**
111 * @return bool|null
112 */
113 public function getRequired(): ?bool
114 {
115 return $this->required;
116 }
117 }
118