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

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

90 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\Server\Core\DTO;
6
7 use WP\McpSchema\Common\Protocol\DTO\Result;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9 use WP\McpSchema\Server\Lifecycle\Union\ServerResultInterface;
10
11 /**
12 * The server's response to a completion/complete request
13 *
14 * @since 2024-11-05
15 *
16 * @mcp-domain Server
17 * @mcp-subdomain Core
18 * @mcp-version 2025-11-25
19 */
20 class CompleteResult extends Result implements ServerResultInterface
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * @since 2024-11-05
26 *
27 * @var \WP\McpSchema\Server\Core\DTO\CompleteResultCompletion
28 */
29 protected CompleteResultCompletion $completion;
30
31 /**
32 * @param \WP\McpSchema\Server\Core\DTO\CompleteResultCompletion $completion @since 2024-11-05
33 * @param array<string, mixed>|null $_meta @since 2024-11-05
34 */
35 public function __construct(
36 CompleteResultCompletion $completion,
37 ?array $_meta = null
38 ) {
39 parent::__construct($_meta);
40 $this->completion = $completion;
41 }
42
43 /**
44 * Creates an instance from an array.
45 *
46 * @param array{
47 * _meta?: array<string, mixed>|null,
48 * completion: array<string, mixed>|\WP\McpSchema\Server\Core\DTO\CompleteResultCompletion
49 * } $data
50 * @phpstan-param array<string, mixed> $data
51 * @return self
52 */
53 public static function fromArray(array $data): self
54 {
55 self::assertRequired($data, ['completion']);
56
57 /** @var \WP\McpSchema\Server\Core\DTO\CompleteResultCompletion $completion */
58 $completion = is_array($data['completion'])
59 ? CompleteResultCompletion::fromArray(self::asArray($data['completion']))
60 : $data['completion'];
61
62 return new self(
63 $completion,
64 self::asArrayOrNull($data['_meta'] ?? null)
65 );
66 }
67
68 /**
69 * Converts the instance to an array.
70 *
71 * @return array<string, mixed>
72 */
73 public function toArray(): array
74 {
75 $result = parent::toArray();
76
77 $result['completion'] = $this->completion->toArray();
78
79 return $result;
80 }
81
82 /**
83 * @return \WP\McpSchema\Server\Core\DTO\CompleteResultCompletion
84 */
85 public function getCompletion(): CompleteResultCompletion
86 {
87 return $this->completion;
88 }
89 }
90