PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
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 / Protocol / DTO / PaginatedResult.php

PaginatedResult.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF trunk, 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