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;
15:
16: /**
17: * The `_meta` extension slot carried by notifications and results.
18: *
19: * @implements Arrayable<array<string, mixed>>
20: *
21: * @see https://modelcontextprotocol.io/specification/2025-11-25/basic#_meta
22: */
23: final readonly class MetaObject implements Arrayable
24: {
25: /**
26: * @param array<string, mixed> $extras
27: */
28: public function __construct(public array $extras = [])
29: {
30: }
31:
32: #[\Override]
33: public static function fromArray(array $data): static
34: {
35: return new self($data);
36: }
37:
38: #[\Override]
39: public function toArray(): array
40: {
41: return $this->extras;
42: }
43:
44: #[\Override]
45: public function jsonSerialize(): array|\stdClass
46: {
47: return [] === $this->extras ? new \stdClass() : $this->extras;
48: }
49: }
50: