PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 All 196 releases
convertkit / vendor / wordpress / php-mcp-schema / src / Common / Protocol / DTO / PaginatedResult.php

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

94 lines 2.2 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\Traits\ValidatesRequiredFields;
8
9 /**
10 * @since 2024-11-05
11 *
12 * @mcp-domain Common
13 * @mcp-subdomain Protocol
14 * @mcp-version 2025-11-25
15 */
16 class PaginatedResult extends Result
17 {
18 use ValidatesRequiredFields;
19
20 /**
21 * Wire keys this class models. Anything else is kept in $additionalProperties.
22 *
23 * @var array<int, string>
24 */
25 private const KNOWN_KEYS = ['_meta', 'nextCursor'];
26
27 /**
28 * An opaque token representing the pagination position after the last returned result.
29 * If present, there may be more results available.
30 *
31 * @since 2024-11-05
32 *
33 * @var string|null
34 */
35 protected ?string $nextCursor;
36
37 /**
38 * @param array<string, mixed>|null $_meta @since 2024-11-05
39 * @param string|null $nextCursor @since 2024-11-05
40 * @param array<string, mixed>|null $additionalProperties
41 */
42 public function __construct(
43 ?array $_meta = null,
44 ?string $nextCursor = null,
45 ?array $additionalProperties = null
46 ) {
47 parent::__construct($_meta, $additionalProperties);
48 $this->nextCursor = $nextCursor;
49 }
50
51 /**
52 * Creates an instance from an array.
53 *
54 * @param array{
55 * _meta?: array<string, mixed>|null,
56 * nextCursor?: string|null
57 * } $data
58 * @phpstan-param array<string, mixed> $data
59 * @return self
60 */
61 public static function fromArray(array $data): self
62 {
63 return new self(
64 self::asArrayOrNull($data['_meta'] ?? null),
65 self::asStringOrNull($data['nextCursor'] ?? null),
66 self::additionalFields($data, self::KNOWN_KEYS)
67 );
68 }
69
70 /**
71 * Converts the instance to an array.
72 *
73 * @return array<string, mixed>
74 */
75 public function toArray(): array
76 {
77 $result = parent::toArray();
78
79 if ($this->nextCursor !== null) {
80 $result['nextCursor'] = $this->nextCursor;
81 }
82
83 return $result;
84 }
85
86 /**
87 * @return string|null
88 */
89 public function getNextCursor(): ?string
90 {
91 return $this->nextCursor;
92 }
93 }
94