ameliabooking
/
vendor
/
wordpress
/
php-mcp-schema
/
src
/
Client
/
Lifecycle
/
DTO
/
ClientCapabilitiesElicitation.php
ameliabooking
/
vendor
/
wordpress
/
php-mcp-schema
/
src
/
Client
/
Lifecycle
/
DTO
Last commit date
ClientCapabilities.php
1 month ago
ClientCapabilitiesElicitation.php
1 month ago
ClientCapabilitiesRoots.php
1 month ago
ClientCapabilitiesSampling.php
1 month ago
ClientCapabilitiesTasks.php
1 month ago
ClientCapabilitiesElicitation.php
96 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace WP\McpSchema\Client\Lifecycle\DTO; |
| 6 | |
| 7 | use WP\McpSchema\Common\AbstractDataTransferObject; |
| 8 | use WP\McpSchema\Common\Traits\ValidatesRequiredFields; |
| 9 | |
| 10 | /** |
| 11 | * Present if the client supports elicitation from the server. |
| 12 | * |
| 13 | * @mcp-domain Client |
| 14 | * @mcp-subdomain Lifecycle |
| 15 | * @mcp-version 2025-11-25 |
| 16 | */ |
| 17 | class ClientCapabilitiesElicitation extends AbstractDataTransferObject |
| 18 | { |
| 19 | use ValidatesRequiredFields; |
| 20 | |
| 21 | /** |
| 22 | * @var object|null |
| 23 | */ |
| 24 | protected ?object $form; |
| 25 | |
| 26 | /** |
| 27 | * @var object|null |
| 28 | */ |
| 29 | protected ?object $url; |
| 30 | |
| 31 | /** |
| 32 | * @param object|null $form |
| 33 | * @param object|null $url |
| 34 | */ |
| 35 | public function __construct( |
| 36 | ?object $form = null, |
| 37 | ?object $url = null |
| 38 | ) { |
| 39 | $this->form = $form; |
| 40 | $this->url = $url; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Creates an instance from an array. |
| 45 | * |
| 46 | * @param array{ |
| 47 | * form?: object|null, |
| 48 | * url?: object|null |
| 49 | * } $data |
| 50 | * @phpstan-param array<string, mixed> $data |
| 51 | * @return self |
| 52 | */ |
| 53 | public static function fromArray(array $data): self |
| 54 | { |
| 55 | return new self( |
| 56 | self::asObjectOrNull($data['form'] ?? null), |
| 57 | self::asObjectOrNull($data['url'] ?? null) |
| 58 | ); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Converts the instance to an array. |
| 63 | * |
| 64 | * @return array<string, mixed> |
| 65 | */ |
| 66 | public function toArray(): array |
| 67 | { |
| 68 | $result = []; |
| 69 | |
| 70 | if ($this->form !== null) { |
| 71 | $result['form'] = $this->form; |
| 72 | } |
| 73 | if ($this->url !== null) { |
| 74 | $result['url'] = $this->url; |
| 75 | } |
| 76 | |
| 77 | return $result; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * @return object|null |
| 82 | */ |
| 83 | public function getForm(): ?object |
| 84 | { |
| 85 | return $this->form; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @return object|null |
| 90 | */ |
| 91 | public function getUrl(): ?object |
| 92 | { |
| 93 | return $this->url; |
| 94 | } |
| 95 | } |
| 96 |