PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
convertkit / vendor / wordpress / php-mcp-schema / src / Client / Elicitation / DTO / ElicitResult.php

ElicitResult.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at vendor/wordpress/php-mcp-schema/src/Client/Elicitation/DTO/ElicitResult.php

130 lines 3.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\Client\Lifecycle\Union\ClientResultInterface;
8 use WP\McpSchema\Common\Protocol\DTO\Result;
9 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
10
11 /**
12 * The client's response to an elicitation request.
13 *
14 * @since 2025-06-18
15 *
16 * @mcp-domain Client
17 * @mcp-subdomain Elicitation
18 * @mcp-version 2025-11-25
19 */
20 class ElicitResult extends Result implements ClientResultInterface
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * Wire keys this class models. Anything else is kept in $additionalProperties.
26 *
27 * @var array<int, string>
28 */
29 private const KNOWN_KEYS = ['_meta', 'action', 'content'];
30
31 /**
32 * The user action in response to the elicitation.
33 * - "accept": User submitted the form/confirmed the action
34 * - "decline": User explicitly decline the action
35 * - "cancel": User dismissed without making an explicit choice
36 *
37 * @since 2025-06-18
38 *
39 * @var 'accept'|'decline'|'cancel'
40 */
41 protected string $action;
42
43 /**
44 * The submitted form data, only present when action is "accept" and mode was "form".
45 * Contains values matching the requested schema.
46 * Omitted for out-of-band mode responses.
47 *
48 * @since 2025-06-18
49 *
50 * @var array<string, string>|null
51 */
52 protected ?array $content;
53
54 /**
55 * @param 'accept'|'decline'|'cancel' $action @since 2025-06-18
56 * @param array<string, mixed>|null $_meta @since 2025-06-18
57 * @param array<string, string>|null $content @since 2025-06-18
58 * @param array<string, mixed>|null $additionalProperties
59 */
60 public function __construct(
61 string $action,
62 ?array $_meta = null,
63 ?array $content = null,
64 ?array $additionalProperties = null
65 ) {
66 parent::__construct($_meta, $additionalProperties);
67 $this->action = $action;
68 $this->content = $content;
69 }
70
71 /**
72 * Creates an instance from an array.
73 *
74 * @param array{
75 * _meta?: array<string, mixed>|null,
76 * action: 'accept'|'decline'|'cancel',
77 * content?: array<string, string>|null
78 * } $data
79 * @phpstan-param array<string, mixed> $data
80 * @return self
81 */
82 public static function fromArray(array $data): self
83 {
84 self::assertRequired($data, ['action']);
85
86 /** @var 'accept'|'decline'|'cancel' $action */
87 $action = self::asString($data['action']);
88
89 return new self(
90 $action,
91 self::asArrayOrNull($data['_meta'] ?? null),
92 self::asStringMapOrNull($data['content'] ?? null),
93 self::additionalFields($data, self::KNOWN_KEYS)
94 );
95 }
96
97 /**
98 * Converts the instance to an array.
99 *
100 * @return array<string, mixed>
101 */
102 public function toArray(): array
103 {
104 $result = parent::toArray();
105
106 $result['action'] = $this->action;
107 if ($this->content !== null) {
108 $result['content'] = $this->content;
109 }
110
111 return $result;
112 }
113
114 /**
115 * @return 'accept'|'decline'|'cancel'
116 */
117 public function getAction(): string
118 {
119 return $this->action;
120 }
121
122 /**
123 * @return array<string, string>|null
124 */
125 public function getContent(): ?array
126 {
127 return $this->content;
128 }
129 }
130