convertkit
/
vendor
/
wordpress
/
php-mcp-schema
/
src
/
Common
/
JsonRpc
/
DTO
/
RequestParamsMeta.php
RequestParamsMeta.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 3.4.3, at vendor/wordpress/php-mcp-schema/src/Common/JsonRpc/DTO/RequestParamsMeta.php
| 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 | * See [General fields: `_meta`](/specification/2025-11-25/basic/index#meta) for notes on `_meta` usage. |
| 12 | * |
| 13 | * @mcp-domain Common |
| 14 | * @mcp-subdomain JsonRpc |
| 15 | * @mcp-version 2025-11-25 |
| 16 | */ |
| 17 | class RequestParamsMeta extends AbstractDataTransferObject |
| 18 | { |
| 19 | use ValidatesRequiredFields; |
| 20 | |
| 21 | /** |
| 22 | * Wire keys this class models. Anything else is kept in $additionalProperties. |
| 23 | * |
| 24 | * @var array<int, string> |
| 25 | */ |
| 26 | private const KNOWN_KEYS = ['progressToken']; |
| 27 | |
| 28 | /** |
| 29 | * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications. |
| 30 | * |
| 31 | * @var string|number|null |
| 32 | */ |
| 33 | protected $progressToken; |
| 34 | |
| 35 | /** |
| 36 | * Keys carried on the wire that this type does not model. Preserved verbatim so unrecognized fields survive a round trip. |
| 37 | * |
| 38 | * @var array<string, mixed>|null |
| 39 | */ |
| 40 | protected ?array $additionalProperties; |
| 41 | |
| 42 | /** |
| 43 | * @param string|number|null $progressToken |
| 44 | * @param array<string, mixed>|null $additionalProperties |
| 45 | */ |
| 46 | public function __construct( |
| 47 | $progressToken = null, |
| 48 | ?array $additionalProperties = null |
| 49 | ) { |
| 50 | $this->progressToken = $progressToken; |
| 51 | $this->additionalProperties = $additionalProperties; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Creates an instance from an array. |
| 56 | * |
| 57 | * @param array{ |
| 58 | * progressToken?: string|number|null |
| 59 | * } $data |
| 60 | * @phpstan-param array<string, mixed> $data |
| 61 | * @return self |
| 62 | */ |
| 63 | public static function fromArray(array $data): self |
| 64 | { |
| 65 | /** @var string|number|null $progressToken */ |
| 66 | $progressToken = isset($data['progressToken']) |
| 67 | ? self::asStringOrNumberOrNull($data['progressToken']) |
| 68 | : null; |
| 69 | |
| 70 | return new self( |
| 71 | $progressToken, |
| 72 | self::additionalFields($data, self::KNOWN_KEYS) |
| 73 | ); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Converts the instance to an array. |
| 78 | * |
| 79 | * @return array<string, mixed> |
| 80 | */ |
| 81 | public function toArray(): array |
| 82 | { |
| 83 | $result = []; |
| 84 | |
| 85 | if ($this->progressToken !== null) { |
| 86 | $result['progressToken'] = $this->progressToken; |
| 87 | } |
| 88 | |
| 89 | return $result + ($this->additionalProperties ?? []); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * @return string|number|null |
| 94 | */ |
| 95 | public function getProgressToken() |
| 96 | { |
| 97 | return $this->progressToken; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return array<string, mixed>|null |
| 102 | */ |
| 103 | public function getAdditionalProperties(): ?array |
| 104 | { |
| 105 | return $this->additionalProperties; |
| 106 | } |
| 107 | } |
| 108 |