PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.4 3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 All 262 releases
wpfunnels / vendor / wordpress / php-mcp-schema / src / Common / Protocol / DTO / PaginatedRequestParams.php

PaginatedRequestParams.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.3, at vendor/wordpress/php-mcp-schema/src/Common/Protocol/DTO/PaginatedRequestParams.php

95 lines 2.3 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\Protocol\DTO;
6
7 use WP\McpSchema\Common\JsonRpc\DTO\RequestParams;
8 use WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta;
9 use WP\McpSchema\Common\Traits\ValidatesRequiredFields;
10
11 /**
12 * Common parameters for paginated requests.
13 *
14 * @since 2025-11-25
15 *
16 * @mcp-domain Common
17 * @mcp-subdomain Protocol
18 * @mcp-version 2025-11-25
19 */
20 class PaginatedRequestParams extends RequestParams
21 {
22 use ValidatesRequiredFields;
23
24 /**
25 * An opaque token representing the current pagination position.
26 * If provided, the server should return results starting after this cursor.
27 *
28 * @since 2025-11-25
29 *
30 * @var string|null
31 */
32 protected ?string $cursor;
33
34 /**
35 * @param \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta @since 2025-11-25
36 * @param string|null $cursor @since 2025-11-25
37 */
38 public function __construct(
39 ?RequestParamsMeta $_meta = null,
40 ?string $cursor = null
41 ) {
42 parent::__construct($_meta);
43 $this->cursor = $cursor;
44 }
45
46 /**
47 * Creates an instance from an array.
48 *
49 * @param array{
50 * _meta?: array<string, mixed>|\WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null,
51 * cursor?: string|null
52 * } $data
53 * @phpstan-param array<string, mixed> $data
54 * @return self
55 */
56 public static function fromArray(array $data): self
57 {
58 /** @var \WP\McpSchema\Common\JsonRpc\DTO\RequestParamsMeta|null $_meta */
59 $_meta = isset($data['_meta'])
60 ? (is_array($data['_meta'])
61 ? RequestParamsMeta::fromArray(self::asArray($data['_meta']))
62 : $data['_meta'])
63 : null;
64
65 return new self(
66 $_meta,
67 self::asStringOrNull($data['cursor'] ?? null)
68 );
69 }
70
71 /**
72 * Converts the instance to an array.
73 *
74 * @return array<string, mixed>
75 */
76 public function toArray(): array
77 {
78 $result = parent::toArray();
79
80 if ($this->cursor !== null) {
81 $result['cursor'] = $this->cursor;
82 }
83
84 return $result;
85 }
86
87 /**
88 * @return string|null
89 */
90 public function getCursor(): ?string
91 {
92 return $this->cursor;
93 }
94 }
95