1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * This file is part of the Nexus MCP SDK package.
7: *
8: * (c) 2026 John Paul E. Balandan, CPA <paulbalandan@gmail.com>
9: *
10: * For the full copyright and license information, please view
11: * the LICENSE file that was distributed with this source code.
12: */
13:
14: namespace Nexus\Mcp\Core\Schema\NotificationParams;
15:
16: use Nexus\Assert\Assert;
17: use Nexus\Mcp\Core\Schema\MetaObject;
18: use Nexus\Mcp\Core\Schema\NotificationParams;
19:
20: /**
21: * Parameters for a `notifications/elicitation/complete` notification.
22: *
23: * @see https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/schema/2025-11-25/schema.ts
24: */
25: final readonly class ElicitationCompleteNotificationParams extends NotificationParams
26: {
27: /**
28: * @var non-empty-string
29: */
30: public string $elicitationId;
31:
32: public function __construct(string $elicitationId, MetaObject $meta = new MetaObject())
33: {
34: Assert::that($elicitationId)->isNonEmptyString('"params.elicitationId" must be a non-empty string.');
35:
36: $this->elicitationId = $elicitationId;
37:
38: parent::__construct($meta);
39: }
40:
41: /**
42: * @param array<string, mixed> $data
43: */
44: #[\Override]
45: public static function fromArray(array $data): static
46: {
47: Assert::that($data)->hasOffset('elicitationId', 'missing the required "elicitationId" key.');
48: $elicitationId = $data['elicitationId'];
49: Assert::that($elicitationId)->isString('"params.elicitationId" must be a string, {type} given.');
50:
51: $meta = new MetaObject();
52:
53: if (\array_key_exists('_meta', $data)) {
54: Assert::that($data['_meta'])
55: ->isArray('"params._meta" must be an object, {type} given.')
56: ->isMap('"params._meta" must be a string-keyed object.')
57: ;
58: $meta = MetaObject::fromArray($data['_meta']);
59: }
60:
61: return new self($elicitationId, $meta);
62: }
63:
64: #[\Override]
65: public function toArray(): array
66: {
67: return [
68: ...parent::toArray(),
69: 'elicitationId' => $this->elicitationId,
70: ];
71: }
72:
73: #[\Override]
74: public function jsonSerialize(): array
75: {
76: return $this->toArray();
77: }
78: }
79: