PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.0
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.0
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / vendor / wordpress / php-mcp-schema / src / Common / JsonRpc / DTO / RequestParams.php

RequestParams.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.3.0, at vendor/wordpress/php-mcp-schema/src/Common/JsonRpc/DTO/RequestParams.php

88 lines 2.0 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\Common\JsonRpc\DTO;
6
7 use WP\McpSchema\Common\AbstractDataTransferObject;
8 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
9
10 /**
11 * Common params for any request.
12 *
13 * @since 2025-11-25
14 *
15 * @mcp-domain Common
16 * @mcp-subdomain JsonRpc
17 * @mcp-version 2025-11-25
18 */
19 class RequestParams extends AbstractDataTransferObject
20 {
21 use ValidatesRequiredFields;
22
23 /**
24 * See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage.
25 *
26 * @since 2025-11-25
27 *
28 * @var \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null
29 */
30 protected ?RequestParamsMeta $_meta;
31
32 /**
33 * @param \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta @since 2025-11-25
34 */
35 public function __construct(
36 ?RequestParamsMeta $_meta = null
37 ) {
38 $this->_meta = $_meta;
39 }
40
41 /**
42 * Creates an instance from an array.
43 *
44 * @param array{
45 * _meta?: array<string, mixed>|\WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null
46 * } $data
47 * @phpstan-param array<string, mixed> $data
48 * @return self
49 */
50 public static function fromArray(array $data): self
51 {
52 /** @var \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta */
53 $_meta = isset($data['_meta'])
54 ? (is_array($data['_meta'])
55 ? RequestParamsMeta::fromArray(self::asArray($data['_meta']))
56 : $data['_meta'])
57 : null;
58
59 return new self(
60 $_meta
61 );
62 }
63
64 /**
65 * Converts the instance to an array.
66 *
67 * @return array<string, mixed>
68 */
69 public function toArray(): array
70 {
71 $result = [];
72
73 if ($this->_meta !== null) {
74 $result['_meta'] = $this->_meta->toArray();
75 }
76
77 return $result;
78 }
79
80 /**
81 * @return \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null
82 */
83 public function get_meta(): ?RequestParamsMeta
84 {
85 return $this->_meta;
86 }
87 }
88