| 1 | <?php |
||
| 9 | class PaginableArray extends Component implements \Countable, PaginatorAwareInterface, \Iterator |
||
| 10 | { |
||
| 11 | use PaginatorTrait; |
||
| 12 | |||
| 13 | /** @var array */ |
||
| 14 | protected $source = []; |
||
| 15 | |||
| 16 | /** @var int */ |
||
| 17 | private $cursor; |
||
| 18 | |||
| 19 | /** @var array */ |
||
| 20 | private $keys = []; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * ArraySource constructor. |
||
| 24 | * |
||
| 25 | * @param array $source |
||
| 26 | */ |
||
| 27 | public function __construct(array $source = []) |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param bool $paginate |
||
| 35 | * @return array |
||
| 36 | */ |
||
| 37 | public function iterate(bool $paginate = true): array |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritdoc} |
||
| 52 | * |
||
| 53 | * @return int |
||
| 54 | */ |
||
| 55 | public function count(): int |
||
| 59 | |||
| 60 | /** |
||
| 61 | * {@inheritdoc} |
||
| 62 | * |
||
| 63 | * @return mixed |
||
| 64 | */ |
||
| 65 | public function current() |
||
| 72 | |||
| 73 | /** |
||
| 74 | * {@inheritdoc} |
||
| 75 | */ |
||
| 76 | public function next() |
||
| 80 | |||
| 81 | /** |
||
| 82 | * {@inheritdoc} |
||
| 83 | * |
||
| 84 | * @return |
||
| 85 | */ |
||
| 86 | public function key(): int |
||
| 90 | |||
| 91 | /** |
||
| 92 | * {@inheritdoc} |
||
| 93 | * |
||
| 94 | * @return bool |
||
| 95 | */ |
||
| 96 | public function valid(): bool |
||
| 100 | |||
| 101 | /** |
||
| 102 | * {@inheritdoc} |
||
| 103 | */ |
||
| 104 | public function rewind() |
||
| 108 | } |