1 | <?php |
||
26 | class CursorSubset extends \IteratorIterator implements \JsonSerializable |
||
27 | { |
||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $total; |
||
32 | |||
33 | /** |
||
34 | * Create a new CursorSubset. |
||
35 | * |
||
36 | * @param \Traversable $iterable The traversable to wrap |
||
37 | * @param int $total The total number of items in the superset |
||
38 | * @throws \RangeException if the total is negative |
||
39 | */ |
||
40 | 4 | public function __construct(\Traversable $iterable, int $total) |
|
48 | |||
49 | /** |
||
50 | * Gets the superset total. |
||
51 | * |
||
52 | * @return - The total number of items in the superset (never negative). |
||
|
|||
53 | */ |
||
54 | 3 | public function getTotal(): int |
|
58 | |||
59 | /** |
||
60 | * Return data which can be serialized with json_encode. |
||
61 | */ |
||
62 | public function jsonSerialize() |
||
63 | { |
||
64 | $it = $this->getInnerIterator(); |
||
65 | return $it instanceof \JsonSerializable ? $it : $this->toArray(); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Converts this thing into an array. |
||
70 | * |
||
71 | * @return array<mixed> The array version of this thing |
||
72 | */ |
||
73 | 3 | public function toArray(): array |
|
87 | } |
||
88 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.