PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / wordpress / php-mcp-schema / src / Client / Elicitation / DTO / UntitledSingleSelectEnumSchema.php
ameliabooking / vendor / wordpress / php-mcp-schema / src / Client / Elicitation / DTO Last commit date
BooleanSchema.php 1 month ago ElicitRequest.php 1 month ago ElicitRequestFormParams.php 1 month ago ElicitRequestFormParamsRequestedSchema.php 1 month ago ElicitRequestURLParams.php 1 month ago ElicitResult.php 1 month ago ElicitationCompleteNotification.php 1 month ago ElicitationCompleteNotificationParams.php 1 month ago LegacyTitledEnumSchema.php 1 month ago NumberSchema.php 1 month ago StringSchema.php 1 month ago TitledMultiSelectEnumSchema.php 1 month ago TitledMultiSelectEnumSchemaItems.php 1 month ago TitledSingleSelectEnumSchema.php 1 month ago UntitledMultiSelectEnumSchema.php 1 month ago UntitledMultiSelectEnumSchemaItems.php 1 month ago UntitledSingleSelectEnumSchema.php 1 month ago
UntitledSingleSelectEnumSchema.php
180 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Client\Elicitation\DTO;
6
7 use WP\McpSchema\Client\Elicitation\Union\SingleSelectEnumSchemaInterface;
8 use WP\McpSchema\Common\AbstractDataTransferObject;
9 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
10
11 /**
12 * Schema for single-selection enumeration without display titles for options.
13 *
14 * @since 2025-11-25
15 *
16 * @mcp-domain Client
17 * @mcp-subdomain Elicitation
18 * @mcp-version 2025-11-25
19 */
20 class UntitledSingleSelectEnumSchema extends AbstractDataTransferObject implements SingleSelectEnumSchemaInterface
21 {
22 use ValidatesRequiredFields;
23
24 public const TYPE = 'string';
25
26 public const DISCRIMINATOR_FIELD = 'type';
27 public const DISCRIMINATOR_VALUE = 'string';
28
29 /**
30 * @since 2025-11-25
31 *
32 * @var 'string'
33 */
34 protected string $type;
35
36 /**
37 * Optional title for the enum field.
38 *
39 * @since 2025-11-25
40 *
41 * @var string|null
42 */
43 protected ?string $title;
44
45 /**
46 * Optional description for the enum field.
47 *
48 * @since 2025-11-25
49 *
50 * @var string|null
51 */
52 protected ?string $description;
53
54 /**
55 * Array of enum values to choose from.
56 *
57 * @since 2025-11-25
58 *
59 * @var array<string>
60 */
61 protected array $enum;
62
63 /**
64 * Optional default value.
65 *
66 * @since 2025-11-25
67 *
68 * @var string|null
69 */
70 protected ?string $default;
71
72 /**
73 * @param array<string> $enum @since 2025-11-25
74 * @param string|null $title @since 2025-11-25
75 * @param string|null $description @since 2025-11-25
76 * @param string|null $default @since 2025-11-25
77 */
78 public function __construct(
79 array $enum,
80 ?string $title = null,
81 ?string $description = null,
82 ?string $default = null
83 ) {
84 $this->type = self::TYPE;
85 $this->enum = $enum;
86 $this->title = $title;
87 $this->description = $description;
88 $this->default = $default;
89 }
90
91 /**
92 * Creates an instance from an array.
93 *
94 * @param array{
95 * type: 'string',
96 * title?: string|null,
97 * description?: string|null,
98 * enum: array<string>,
99 * default?: string|null
100 * } $data
101 * @phpstan-param array<string, mixed> $data
102 * @return self
103 */
104 public static function fromArray(array $data): self
105 {
106 self::assertRequired($data, ['enum']);
107
108 return new self(
109 self::asStringArray($data['enum']),
110 self::asStringOrNull($data['title'] ?? null),
111 self::asStringOrNull($data['description'] ?? null),
112 self::asStringOrNull($data['default'] ?? null)
113 );
114 }
115
116 /**
117 * Converts the instance to an array.
118 *
119 * @return array<string, mixed>
120 */
121 public function toArray(): array
122 {
123 $result = [];
124
125 $result['type'] = $this->type;
126 if ($this->title !== null) {
127 $result['title'] = $this->title;
128 }
129 if ($this->description !== null) {
130 $result['description'] = $this->description;
131 }
132 $result['enum'] = $this->enum;
133 if ($this->default !== null) {
134 $result['default'] = $this->default;
135 }
136
137 return $result;
138 }
139
140 /**
141 * @return 'string'
142 */
143 public function getType(): string
144 {
145 return $this->type;
146 }
147
148 /**
149 * @return string|null
150 */
151 public function getTitle(): ?string
152 {
153 return $this->title;
154 }
155
156 /**
157 * @return string|null
158 */
159 public function getDescription(): ?string
160 {
161 return $this->description;
162 }
163
164 /**
165 * @return array<string>
166 */
167 public function getEnum(): array
168 {
169 return $this->enum;
170 }
171
172 /**
173 * @return string|null
174 */
175 public function getDefault(): ?string
176 {
177 return $this->default;
178 }
179 }
180