PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
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 / Common / Tasks / DTO / GetTaskResult.php
ameliabooking / vendor / wordpress / php-mcp-schema / src / Common / Tasks / DTO Last commit date
CancelTaskRequest.php 1 month ago CancelTaskRequestParams.php 1 month ago CancelTaskResult.php 1 month ago GetTaskRequest.php 1 month ago GetTaskRequestParams.php 1 month ago GetTaskResult.php 1 month ago ListTasksRequest.php 1 month ago ListTasksResult.php 1 month ago TaskAugmentedRequestParams.php 1 month ago TaskStatusNotification.php 1 month ago
GetTaskResult.php
237 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Common\Tasks\DTO;
6
7 use WP\McpSchema\Common\Protocol\DTO\Result;
8 use WP\McpSchema\Client\Lifecycle\Union\ClientResultInterface;
9 use WP\McpSchema\Server\Lifecycle\Union\ServerResultInterface;
10
11 /**
12 * The response to a tasks/get request.
13 *
14 * This class represents an intersection type combining properties from:
15 * - {@see Result}
16 * - {@see Task}
17 *
18 * In TypeScript, this is defined as: `type GetTaskResult = Result & Task`
19 *
20 * PHP requires actual classes for union interface implementation, so this class
21 * extends Result and merges properties from: Task
22 *
23 * Implements union interfaces:
24 * - {@see ClientResultInterface}
25 * - {@see ServerResultInterface}
26 *
27 * @since 2025-11-25
28 *
29 * @mcp-domain Common
30 * @mcp-subdomain Tasks
31 * @mcp-version 2025-11-25
32 */
33 class GetTaskResult extends Result implements ClientResultInterface, ServerResultInterface
34 {
35 /**
36 * The task identifier.
37 *
38 * @since 2025-11-25
39 *
40 * @var string
41 */
42 protected string $taskId;
43
44 /**
45 * Current task state.
46 *
47 * @since 2025-11-25
48 *
49 * @var 'working'|'input_required'|'completed'|'failed'|'cancelled'
50 */
51 protected string $status;
52
53 /**
54 * Optional human-readable message describing the current task state.
55 * This can provide context for any status, including:
56 * - Reasons for "cancelled" status
57 * - Summaries for "completed" status
58 * - Diagnostic information for "failed" status (e.g., error details, what went wrong)
59 *
60 * @since 2025-11-25
61 *
62 * @var string|null
63 */
64 protected ?string $statusMessage = null;
65
66 /**
67 * ISO 8601 timestamp when the task was created.
68 *
69 * @since 2025-11-25
70 *
71 * @var string
72 */
73 protected string $createdAt;
74
75 /**
76 * ISO 8601 timestamp when the task was last updated.
77 *
78 * @since 2025-11-25
79 *
80 * @var string
81 */
82 protected string $lastUpdatedAt;
83
84 /**
85 * Actual retention duration from creation in milliseconds, null for unlimited.
86 *
87 * @since 2025-11-25
88 *
89 * @var int|null
90 */
91 protected ?int $ttl = null;
92
93 /**
94 * Suggested polling interval in milliseconds.
95 *
96 * @since 2025-11-25
97 *
98 * @var int|null
99 */
100 protected ?int $pollInterval = null;
101
102 /**
103 * @param string $taskId @since 2025-11-25
104 * @param 'working'|'input_required'|'completed'|'failed'|'cancelled' $status @since 2025-11-25
105 * @param string $createdAt @since 2025-11-25
106 * @param string $lastUpdatedAt @since 2025-11-25
107 * @param int $ttl @since 2025-11-25
108 * @param array<string, mixed>|null $_meta @since 2025-11-25
109 * @param string|null $statusMessage @since 2025-11-25
110 * @param int|null $pollInterval @since 2025-11-25
111 */
112 public function __construct(
113 string $taskId,
114 string $status,
115 string $createdAt,
116 string $lastUpdatedAt,
117 int $ttl,
118 ?array $_meta = null,
119 ?string $statusMessage = null,
120 ?int $pollInterval = null
121 ) {
122 parent::__construct($_meta);
123 $this->taskId = $taskId;
124 $this->status = $status;
125 $this->statusMessage = $statusMessage;
126 $this->createdAt = $createdAt;
127 $this->lastUpdatedAt = $lastUpdatedAt;
128 $this->ttl = $ttl;
129 $this->pollInterval = $pollInterval;
130 }
131
132 /**
133 * Creates an instance from an array.
134 *
135 * @param array<string, mixed> $data
136 * @return self
137 */
138 public static function fromArray(array $data): self
139 {
140 self::assertRequired($data, ['taskId', 'status', 'createdAt', 'lastUpdatedAt', 'ttl']);
141
142 /** @var 'working'|'input_required'|'completed'|'failed'|'cancelled' $status */
143 $status = self::asString($data['status']);
144
145 return new self(
146 self::asString($data['taskId']),
147 $status,
148 self::asString($data['createdAt']),
149 self::asString($data['lastUpdatedAt']),
150 self::asInt($data['ttl']),
151 self::asArrayOrNull($data['_meta'] ?? null),
152 self::asStringOrNull($data['statusMessage'] ?? null),
153 self::asIntOrNull($data['pollInterval'] ?? null)
154 );
155 }
156
157 /**
158 * Converts the instance to an array.
159 *
160 * @return array<string, mixed>
161 */
162 public function toArray(): array
163 {
164 $result = parent::toArray();
165
166 $result['taskId'] = $this->taskId;
167 $result['status'] = $this->status;
168 if ($this->statusMessage !== null) {
169 $result['statusMessage'] = $this->statusMessage;
170 }
171 $result['createdAt'] = $this->createdAt;
172 $result['lastUpdatedAt'] = $this->lastUpdatedAt;
173 $result['ttl'] = $this->ttl;
174 if ($this->pollInterval !== null) {
175 $result['pollInterval'] = $this->pollInterval;
176 }
177
178 return $result;
179 }
180
181 /**
182 * @return string
183 */
184 public function getTaskId(): string
185 {
186 return $this->taskId;
187 }
188
189 /**
190 * @return 'working'|'input_required'|'completed'|'failed'|'cancelled'
191 */
192 public function getStatus(): string
193 {
194 return $this->status;
195 }
196
197 /**
198 * @return string|null
199 */
200 public function getStatusMessage(): ?string
201 {
202 return $this->statusMessage;
203 }
204
205 /**
206 * @return string
207 */
208 public function getCreatedAt(): string
209 {
210 return $this->createdAt;
211 }
212
213 /**
214 * @return string
215 */
216 public function getLastUpdatedAt(): string
217 {
218 return $this->lastUpdatedAt;
219 }
220
221 /**
222 * @return int|null
223 */
224 public function getTtl(): ?int
225 {
226 return $this->ttl;
227 }
228
229 /**
230 * @return int|null
231 */
232 public function getPollInterval(): ?int
233 {
234 return $this->pollInterval;
235 }
236 }
237