| Total Complexity | 3 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class Paginator implements AdapterInterface |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * @var \Goldoni\Builder\Query |
||
| 21 | */ |
||
| 22 | private $query; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Paginator constructor. |
||
| 26 | * |
||
| 27 | * @param \Goldoni\Builder\Query $query |
||
| 28 | */ |
||
| 29 | public function __construct(Query $query) |
||
| 30 | { |
||
| 31 | $this->query = $query; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Returns the number of results. |
||
| 36 | * |
||
| 37 | * @throws \Exception |
||
| 38 | * |
||
| 39 | * @return int the number of results |
||
| 40 | */ |
||
| 41 | public function getNbResults() |
||
| 42 | { |
||
| 43 | return $this->query->count(); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Returns an slice of the results. |
||
| 48 | * |
||
| 49 | * @param int $offset the offset |
||
| 50 | * @param int $length the length |
||
| 51 | * |
||
| 52 | * @return array|\Traversable the slice |
||
| 53 | */ |
||
| 54 | public function getSlice($offset, $length) |
||
| 57 | } |
||
| 58 | } |
||
| 59 |