PluginProbe
ZIP AI – AI Website Builder & AI Agent (Beta) / 0.0.8
ZIP AI – AI Website Builder & AI Agent (Beta) v0.0.8
0.0.10 0.0.9 trunk 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8
zip-ai / lib / php-mcp-schema / src / Server / Resources / DTO / ResourceRequestParams.php

ResourceRequestParams.php in ZIP AI – AI Website Builder & AI Agent (Beta) 0.0.8, at lib/php-mcp-schema/src/Server/Resources/DTO/ResourceRequestParams.php

94 lines 2.1 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\Resources\DTO;
6
7 use WP\McpSchema\Common\JsonRpc\DTO\RequestParams;
8 use WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta;
9 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
10
11 /**
12 * Common parameters when working with resources.
13 *
14 * @since 2025-11-25
15 *
16 * @mcp-domain Server
17 * @mcp-subdomain Resources
18 * @mcp-version 2025-11-25
19 */
20 class ResourceRequestParams extends RequestParams
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * The URI of the resource. The URI can use any protocol; it is up to the server how to interpret it.
26 *
27 * @since 2025-11-25
28 *
29 * @var string
30 */
31 protected string $uri;
32
33 /**
34 * @param string $uri @since 2025-11-25
35 * @param \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta @since 2025-11-25
36 */
37 public function __construct(
38 string $uri,
39 ?RequestParamsMeta $_meta = null
40 ) {
41 parent::__construct($_meta);
42 $this->uri = $uri;
43 }
44
45 /**
46 * Creates an instance from an array.
47 *
48 * @param array{
49 * _meta?: array<string, mixed>|\WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null,
50 * uri: string
51 * } $data
52 * @phpstan-param array<string, mixed> $data
53 * @return self
54 */
55 public static function fromArray(array $data): self
56 {
57 self::assertRequired($data, ['uri']);
58
59 /** @var \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta */
60 $_meta = isset($data['_meta'])
61 ? (is_array($data['_meta'])
62 ? RequestParamsMeta::fromArray(self::asArray($data['_meta']))
63 : $data['_meta'])
64 : null;
65
66 return new self(
67 self::asString($data['uri']),
68 $_meta
69 );
70 }
71
72 /**
73 * Converts the instance to an array.
74 *
75 * @return array<string, mixed>
76 */
77 public function toArray(): array
78 {
79 $result = parent::toArray();
80
81 $result['uri'] = $this->uri;
82
83 return $result;
84 }
85
86 /**
87 * @return string
88 */
89 public function getUri(): string
90 {
91 return $this->uri;
92 }
93 }
94