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 / Core / DTO / ResourceTemplateReference.php

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

101 lines 1.8 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\Core\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * A reference to a resource or resource template definition.
12 *
13 * @since 2025-06-18
14 *
15 * @mcp-domain Server
16 * @mcp-subdomain Core
17 * @mcp-version 2025-11-25
18 */
19 class ResourceTemplateReference extends AbstractDataTransferObject
20 {
21 use ValidatesRequiredFields;
22
23 public const TYPE = 'ref/resource';
24
25 /**
26 * @since 2025-06-18
27 *
28 * @var 'ref/resource'
29 */
30 protected string $type;
31
32 /**
33 * The URI or URI template of the resource.
34 *
35 * @since 2025-06-18
36 *
37 * @var string
38 */
39 protected string $uri;
40
41 /**
42 * @param string $uri @since 2025-06-18
43 */
44 public function __construct(
45 string $uri
46 ) {
47 $this->type = self::TYPE;
48 $this->uri = $uri;
49 }
50
51 /**
52 * Creates an instance from an array.
53 *
54 * @param array{
55 * type: 'ref/resource',
56 * uri: string
57 * } $data
58 * @phpstan-param array<string, mixed> $data
59 * @return self
60 */
61 public static function fromArray(array $data): self
62 {
63 self::assertRequired($data, ['uri']);
64
65 return new self(
66 self::asString($data['uri'])
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 $result['type'] = $this->type;
80 $result['uri'] = $this->uri;
81
82 return $result;
83 }
84
85 /**
86 * @return 'ref/resource'
87 */
88 public function getType(): string
89 {
90 return $this->type;
91 }
92
93 /**
94 * @return string
95 */
96 public function getUri(): string
97 {
98 return $this->uri;
99 }
100 }
101