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 / Logging / DTO / LoggingMessageNotificationParams.php

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

137 lines 3.2 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\Logging\DTO;
6
7 use WP\McpSchema\Common\JsonRpc\DTO\NotificationParams;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Parameters for a `notifications/message` notification.
12 *
13 * @since 2025-11-25
14 *
15 * @mcp-domain Server
16 * @mcp-subdomain Logging
17 * @mcp-version 2025-11-25
18 */
19 class LoggingMessageNotificationParams extends NotificationParams
20 {
21 use ValidatesRequiredFields;
22
23 /**
24 * The severity of this log message.
25 *
26 * @since 2025-11-25
27 *
28 * @var 'debug'|'info'|'notice'|'warning'|'error'|'critical'|'alert'|'emergency'
29 */
30 protected string $level;
31
32 /**
33 * An optional name of the logger issuing this message.
34 *
35 * @since 2025-11-25
36 *
37 * @var string|null
38 */
39 protected ?string $logger;
40
41 /**
42 * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
43 *
44 * @since 2025-11-25
45 *
46 * @var mixed
47 */
48 protected $data;
49
50 /**
51 * @param 'debug'|'info'|'notice'|'warning'|'error'|'critical'|'alert'|'emergency' $level @since 2025-11-25
52 * @param mixed $data @since 2025-11-25
53 * @param array<string, mixed>|null $_meta @since 2025-11-25
54 * @param string|null $logger @since 2025-11-25
55 */
56 public function __construct(
57 string $level,
58 $data,
59 ?array $_meta = null,
60 ?string $logger = null
61 ) {
62 parent::__construct($_meta);
63 $this->level = $level;
64 $this->data = $data;
65 $this->logger = $logger;
66 }
67
68 /**
69 * Creates an instance from an array.
70 *
71 * @param array{
72 * _meta?: array<string, mixed>|null,
73 * level: 'debug'|'info'|'notice'|'warning'|'error'|'critical'|'alert'|'emergency',
74 * logger?: string|null,
75 * data: mixed
76 * } $data
77 * @phpstan-param array<string, mixed> $data
78 * @return self
79 */
80 public static function fromArray(array $data): self
81 {
82 self::assertRequired($data, ['level', 'data']);
83
84 /** @var 'debug'|'info'|'notice'|'warning'|'error'|'critical'|'alert'|'emergency' $level */
85 $level = self::asString($data['level']);
86
87 return new self(
88 $level,
89 $data['data'],
90 self::asArrayOrNull($data['_meta'] ?? null),
91 self::asStringOrNull($data['logger'] ?? null)
92 );
93 }
94
95 /**
96 * Converts the instance to an array.
97 *
98 * @return array<string, mixed>
99 */
100 public function toArray(): array
101 {
102 $result = parent::toArray();
103
104 $result['level'] = $this->level;
105 if ($this->logger !== null) {
106 $result['logger'] = $this->logger;
107 }
108 $result['data'] = $this->data;
109
110 return $result;
111 }
112
113 /**
114 * @return 'debug'|'info'|'notice'|'warning'|'error'|'critical'|'alert'|'emergency'
115 */
116 public function getLevel(): string
117 {
118 return $this->level;
119 }
120
121 /**
122 * @return string|null
123 */
124 public function getLogger(): ?string
125 {
126 return $this->logger;
127 }
128
129 /**
130 * @return mixed
131 */
132 public function getData()
133 {
134 return $this->data;
135 }
136 }
137