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 / Common / Protocol / DTO / PaginatedRequestParams.php

PaginatedRequestParams.php in ZIP AI – AI Website Builder & AI Agent (Beta) 0.0.8, at lib/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