PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / trunk
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). vtrunk
3.0.3 3.0.2 3.0.1 trunk 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.3.0 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.91 2.7.92 2.7.93 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0
commercebird / vendor / wordpress / php-mcp-schema / src / Server / Logging / DTO / LoggingMessageNotificationParams.php
commercebird / vendor / wordpress / php-mcp-schema / src / Server / Logging / DTO Last commit date
LoggingMessageNotification.php 2 months ago LoggingMessageNotificationParams.php 2 months ago SetLevelRequest.php 2 months ago SetLevelRequestParams.php 2 months ago
LoggingMessageNotificationParams.php
137 lines
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