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 / Server / Resources / DTO / ResourceContents.php
commercebird / vendor / wordpress / php-mcp-schema / src / Server / Resources / DTO Last commit date
ListResourceTemplatesRequest.php 3 months ago ListResourceTemplatesResult.php 3 months ago ListResourcesRequest.php 3 months ago ListResourcesResult.php 3 months ago ReadResourceRequest.php 3 months ago ReadResourceRequestParams.php 3 months ago ReadResourceResult.php 3 months ago Resource.php 3 months ago ResourceContents.php 3 months ago ResourceLink.php 3 months ago ResourceListChangedNotification.php 3 months ago ResourceRequestParams.php 3 months ago ResourceTemplate.php 3 months ago ResourceUpdatedNotification.php 3 months ago ResourceUpdatedNotificationParams.php 3 months ago SubscribeRequest.php 3 months ago SubscribeRequestParams.php 3 months ago UnsubscribeRequest.php 3 months ago UnsubscribeRequestParams.php 3 months ago
ResourceContents.php
132 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace WP\McpSchema\Server\Resources\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * The contents of a specific resource or sub-resource.
12 *
13 * @since 2024-11-05
14 * @last-updated 2025-06-18 (added properties: _meta)
15 *
16 * @mcp-domain Server
17 * @mcp-subdomain Resources
18 * @mcp-version 2025-11-25
19 */
20 class ResourceContents extends AbstractDataTransferObject
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * The URI of this resource.
26 *
27 * @since 2024-11-05
28 *
29 * @var string
30 */
31 protected string $uri;
32
33 /**
34 * The MIME type of this resource, if known.
35 *
36 * @since 2024-11-05
37 *
38 * @var string|null
39 */
40 protected ?string $mimeType;
41
42 /**
43 * See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.
44 *
45 * @since 2025-06-18
46 *
47 * @var array<string, mixed>|null
48 */
49 protected ?array $_meta;
50
51 /**
52 * @param string $uri @since 2024-11-05
53 * @param string|null $mimeType @since 2024-11-05
54 * @param array<string, mixed>|null $_meta @since 2025-06-18
55 */
56 public function __construct(
57 string $uri,
58 ?string $mimeType = null,
59 ?array $_meta = null
60 ) {
61 $this->uri = $uri;
62 $this->mimeType = $mimeType;
63 $this->_meta = $_meta;
64 }
65
66 /**
67 * Creates an instance from an array.
68 *
69 * @param array{
70 * uri: string,
71 * mimeType?: string|null,
72 * _meta?: array<string, mixed>|null
73 * } $data
74 * @phpstan-param array<string, mixed> $data
75 * @return self
76 */
77 public static function fromArray(array $data): self
78 {
79 self::assertRequired($data, ['uri']);
80
81 return new self(
82 self::asString($data['uri']),
83 self::asStringOrNull($data['mimeType'] ?? null),
84 self::asArrayOrNull($data['_meta'] ?? null)
85 );
86 }
87
88 /**
89 * Converts the instance to an array.
90 *
91 * @return array<string, mixed>
92 */
93 public function toArray(): array
94 {
95 $result = [];
96
97 $result['uri'] = $this->uri;
98 if ($this->mimeType !== null) {
99 $result['mimeType'] = $this->mimeType;
100 }
101 if ($this->_meta !== null) {
102 $result['_meta'] = $this->_meta;
103 }
104
105 return $result;
106 }
107
108 /**
109 * @return string
110 */
111 public function getUri(): string
112 {
113 return $this->uri;
114 }
115
116 /**
117 * @return string|null
118 */
119 public function getMimeType(): ?string
120 {
121 return $this->mimeType;
122 }
123
124 /**
125 * @return array<string, mixed>|null
126 */
127 public function get_meta(): ?array
128 {
129 return $this->_meta;
130 }
131 }
132