PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / trunk
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). vtrunk
3.0.3 3.0.2 3.0.1 trunk 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.3.0 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.91 2.7.92 2.7.93 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0
commercebird / vendor / wordpress / php-mcp-schema / src / Client / Roots / DTO / Root.php
commercebird / vendor / wordpress / php-mcp-schema / src / Client / Roots / DTO Last commit date
ListRootsRequest.php 3 months ago ListRootsResult.php 3 months ago Root.php 3 months ago RootsListChangedNotification.php 3 months ago
Root.php
136 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Client\Roots\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Represents a root directory or file that the server can operate on.
12 *
13 * @since 2024-11-05
14 * @last-updated 2025-06-18 (added properties: _meta)
15 *
16 * @mcp-domain Client
17 * @mcp-subdomain Roots
18 * @mcp-version 2025-11-25
19 */
20 class Root extends AbstractDataTransferObject
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * The URI identifying the root. This *must* start with file:// for now.
26 * This restriction may be relaxed in future versions of the protocol to allow
27 * other URI schemes.
28 *
29 * @since 2024-11-05
30 *
31 * @var string
32 */
33 protected string $uri;
34
35 /**
36 * An optional name for the root. This can be used to provide a human-readable
37 * identifier for the root, which may be useful for display purposes or for
38 * referencing the root in other parts of the application.
39 *
40 * @since 2024-11-05
41 *
42 * @var string|null
43 */
44 protected ?string $name;
45
46 /**
47 * See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.
48 *
49 * @since 2025-06-18
50 *
51 * @var array<string, mixed>|null
52 */
53 protected ?array $_meta;
54
55 /**
56 * @param string $uri @since 2024-11-05
57 * @param string|null $name @since 2024-11-05
58 * @param array<string, mixed>|null $_meta @since 2025-06-18
59 */
60 public function __construct(
61 string $uri,
62 ?string $name = null,
63 ?array $_meta = null
64 ) {
65 $this->uri = $uri;
66 $this->name = $name;
67 $this->_meta = $_meta;
68 }
69
70 /**
71 * Creates an instance from an array.
72 *
73 * @param array{
74 * uri: string,
75 * name?: string|null,
76 * _meta?: array<string, mixed>|null
77 * } $data
78 * @phpstan-param array<string, mixed> $data
79 * @return self
80 */
81 public static function fromArray(array $data): self
82 {
83 self::assertRequired($data, ['uri']);
84
85 return new self(
86 self::asString($data['uri']),
87 self::asStringOrNull($data['name'] ?? null),
88 self::asArrayOrNull($data['_meta'] ?? null)
89 );
90 }
91
92 /**
93 * Converts the instance to an array.
94 *
95 * @return array<string, mixed>
96 */
97 public function toArray(): array
98 {
99 $result = [];
100
101 $result['uri'] = $this->uri;
102 if ($this->name !== null) {
103 $result['name'] = $this->name;
104 }
105 if ($this->_meta !== null) {
106 $result['_meta'] = $this->_meta;
107 }
108
109 return $result;
110 }
111
112 /**
113 * @return string
114 */
115 public function getUri(): string
116 {
117 return $this->uri;
118 }
119
120 /**
121 * @return string|null
122 */
123 public function getName(): ?string
124 {
125 return $this->name;
126 }
127
128 /**
129 * @return array<string, mixed>|null
130 */
131 public function get_meta(): ?array
132 {
133 return $this->_meta;
134 }
135 }
136