PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.0
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.0
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / wordpress / php-mcp-schema / src / Server / Tools / DTO / ToolExecution.php

ToolExecution.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.3.0, at vendor/wordpress/php-mcp-schema/src/Server/Tools/DTO/ToolExecution.php

94 lines 2.2 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\Tools\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Execution-related properties for a tool.
12 *
13 * @since 2025-11-25
14 *
15 * @mcp-domain Server
16 * @mcp-subdomain Tools
17 * @mcp-version 2025-11-25
18 */
19 class ToolExecution extends AbstractDataTransferObject
20 {
21 use ValidatesRequiredFields;
22
23 /**
24 * Indicates whether this tool supports task-augmented execution.
25 * This allows clients to handle long-running operations through polling
26 * the task system.
27 *
28 * - "forbidden": Tool does not support task-augmented execution (default when absent)
29 * - "optional": Tool may support task-augmented execution
30 * - "required": Tool requires task-augmented execution
31 *
32 * Default: "forbidden"
33 *
34 * @since 2025-11-25
35 *
36 * @var 'forbidden'|'optional'|'required'|null
37 */
38 protected ?string $taskSupport;
39
40 /**
41 * @param 'forbidden'|'optional'|'required'|null $taskSupport @since 2025-11-25
42 */
43 public function __construct(
44 ?string $taskSupport = null
45 ) {
46 $this->taskSupport = $taskSupport;
47 }
48
49 /**
50 * Creates an instance from an array.
51 *
52 * @param array{
53 * taskSupport?: 'forbidden'|'optional'|'required'|null
54 * } $data
55 * @phpstan-param array<string, mixed> $data
56 * @return self
57 */
58 public static function fromArray(array $data): self
59 {
60 /** @var 'forbidden'|'optional'|'required'|null $taskSupport */
61 $taskSupport = isset($data['taskSupport'])
62 ? self::asStringOrNull($data['taskSupport'])
63 : null;
64
65 return new self(
66 $taskSupport
67 );
68 }
69
70 /**
71 * Converts the instance to an array.
72 *
73 * @return array<string, mixed>
74 */
75 public function toArray(): array
76 {
77 $result = [];
78
79 if ($this->taskSupport !== null) {
80 $result['taskSupport'] = $this->taskSupport;
81 }
82
83 return $result;
84 }
85
86 /**
87 * @return 'forbidden'|'optional'|'required'|null
88 */
89 public function getTaskSupport(): ?string
90 {
91 return $this->taskSupport;
92 }
93 }
94