| 1 |
<?php |
| 2 |
|
| 3 |
namespace ipl\Stdlib\Contract; |
| 4 |
|
| 5 |
use Countable; |
| 6 |
|
| 7 |
/** |
| 8 |
* Support limit and offset for paginated result sets |
| 9 |
*/ |
| 10 |
interface Paginatable extends Countable |
| 11 |
{ |
| 12 |
/** |
| 13 |
* Get whether a limit is set |
| 14 |
* |
| 15 |
* @return bool |
| 16 |
*/ |
| 17 |
public function hasLimit(): bool; |
| 18 |
|
| 19 |
/** |
| 20 |
* Get the limit |
| 21 |
* |
| 22 |
* @return ?int |
| 23 |
*/ |
| 24 |
public function getLimit(): ?int; |
| 25 |
|
| 26 |
/** |
| 27 |
* Set the limit |
| 28 |
* |
| 29 |
* @param ?int $limit Maximum number of items to return. If you want to disable the limit, |
| 30 |
* it is best practice to use null or a negative value |
| 31 |
* |
| 32 |
* @return $this |
| 33 |
*/ |
| 34 |
public function limit(?int $limit): static; |
| 35 |
|
| 36 |
/** |
| 37 |
* Get whether an offset is set |
| 38 |
* |
| 39 |
* @return bool |
| 40 |
*/ |
| 41 |
public function hasOffset(): bool; |
| 42 |
|
| 43 |
/** |
| 44 |
* Get the offset |
| 45 |
* |
| 46 |
* @return ?int |
| 47 |
*/ |
| 48 |
public function getOffset(): ?int; |
| 49 |
|
| 50 |
/** |
| 51 |
* Set the offset |
| 52 |
* |
| 53 |
* @param ?int $offset Start result set after this many rows. If you want to disable the offset, |
| 54 |
* it is best practice to use null or a negative value |
| 55 |
* |
| 56 |
* @return $this |
| 57 |
*/ |
| 58 |
public function offset(?int $offset): static; |
| 59 |
} |