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 / Server / Resources / DTO / ResourceContents.php
ameliabooking / vendor / wordpress / php-mcp-schema / src / Server / Resources / DTO Last commit date
ListResourceTemplatesRequest.php 1 month ago ListResourceTemplatesResult.php 1 month ago ListResourcesRequest.php 1 month ago ListResourcesResult.php 1 month ago ReadResourceRequest.php 1 month ago ReadResourceRequestParams.php 1 month ago ReadResourceResult.php 1 month ago Resource.php 1 month ago ResourceContents.php 1 month ago ResourceLink.php 1 month ago ResourceListChangedNotification.php 1 month ago ResourceRequestParams.php 1 month ago ResourceTemplate.php 1 month ago ResourceUpdatedNotification.php 1 month ago ResourceUpdatedNotificationParams.php 1 month ago SubscribeRequest.php 1 month ago SubscribeRequestParams.php 1 month ago UnsubscribeRequest.php 1 month ago UnsubscribeRequestParams.php 1 month 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