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 / PromptReference.php

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

88 lines 1.7 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\Protocol\DTO\BaseMetadata;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Identifies a prompt.
12 *
13 * @since 2024-11-05
14 * @last-updated 2025-06-18 (added properties: title)
15 *
16 * @mcp-domain Server
17 * @mcp-subdomain Core
18 * @mcp-version 2025-11-25
19 */
20 class PromptReference extends BaseMetadata
21 {
22 use ValidatesRequiredFields;
23
24 public const TYPE = 'ref/prompt';
25
26 /**
27 * @since 2024-11-05
28 *
29 * @var 'ref/prompt'
30 */
31 protected string $type;
32
33 /**
34 * @param string $name @since 2024-11-05
35 * @param string|null $title @since 2025-06-18
36 */
37 public function __construct(
38 string $name,
39 ?string $title = null
40 ) {
41 parent::__construct($name, $title);
42 $this->type = self::TYPE;
43 }
44
45 /**
46 * Creates an instance from an array.
47 *
48 * @param array{
49 * name: string,
50 * title?: string|null,
51 * type: 'ref/prompt'
52 * } $data
53 * @phpstan-param array<string, mixed> $data
54 * @return self
55 */
56 public static function fromArray(array $data): self
57 {
58 self::assertRequired($data, ['name']);
59
60 return new self(
61 self::asString($data['name']),
62 self::asStringOrNull($data['title'] ?? null)
63 );
64 }
65
66 /**
67 * Converts the instance to an array.
68 *
69 * @return array<string, mixed>
70 */
71 public function toArray(): array
72 {
73 $result = parent::toArray();
74
75 $result['type'] = $this->type;
76
77 return $result;
78 }
79
80 /**
81 * @return 'ref/prompt'
82 */
83 public function getType(): string
84 {
85 return $this->type;
86 }
87 }
88