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 / Client / Elicitation / DTO / ElicitRequestFormParamsRequestedSchema.php

ElicitRequestFormParamsRequestedSchema.php in ZIP AI – AI Website Builder & AI Agent (Beta) 0.0.8, at lib/php-mcp-schema/src/Client/Elicitation/DTO/ElicitRequestFormParamsRequestedSchema.php

115 lines 2.3 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\Client\Elicitation\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * A restricted subset of JSON Schema.
12 * Only top-level properties are allowed, without nesting.
13 *
14 * @mcp-domain Client
15 * @mcp-subdomain Elicitation
16 * @mcp-version 2025-11-25
17 */
18 class ElicitRequestFormParamsRequestedSchema extends AbstractDataTransferObject
19 {
20 use ValidatesRequiredFields;
21
22 public const TYPE = 'object';
23
24 /**
25 * @var string|null
26 */
27 protected ?string $schema;
28
29 /**
30 * @var 'object'
31 */
32 protected string $type;
33
34 /**
35 * @var array<string>|null
36 */
37 protected ?array $required;
38
39 /**
40 * @param string|null $schema
41 * @param array<string>|null $required
42 */
43 public function __construct(
44 ?string $schema = null,
45 ?array $required = null
46 ) {
47 $this->type = self::TYPE;
48 $this->schema = $schema;
49 $this->required = $required;
50 }
51
52 /**
53 * Creates an instance from an array.
54 *
55 * @param array{
56 * '$schema'?: string|null,
57 * type: 'object',
58 * required?: array<string>|null
59 * } $data
60 * @phpstan-param array<string, mixed> $data
61 * @return self
62 */
63 public static function fromArray(array $data): self
64 {
65 return new self(
66 self::asStringOrNull($data['$schema'] ?? null),
67 self::asStringArrayOrNull($data['required'] ?? null)
68 );
69 }
70
71 /**
72 * Converts the instance to an array.
73 *
74 * @return array<string, mixed>
75 */
76 public function toArray(): array
77 {
78 $result = [];
79
80 if ($this->schema !== null) {
81 $result['$schema'] = $this->schema;
82 }
83 $result['type'] = $this->type;
84 if ($this->required !== null) {
85 $result['required'] = $this->required;
86 }
87
88 return $result;
89 }
90
91 /**
92 * @return string|null
93 */
94 public function getSchema(): ?string
95 {
96 return $this->schema;
97 }
98
99 /**
100 * @return 'object'
101 */
102 public function getType(): string
103 {
104 return $this->type;
105 }
106
107 /**
108 * @return array<string>|null
109 */
110 public function getRequired(): ?array
111 {
112 return $this->required;
113 }
114 }
115