@@ -8,64 +8,64 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Paginator extends BasePaginator |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * @var IdiormDbal |
|
| 13 | - */ |
|
| 14 | - private $dbal; |
|
| 11 | + /** |
|
| 12 | + * @var IdiormDbal |
|
| 13 | + */ |
|
| 14 | + private $dbal; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var array|IdiormResultSet |
|
| 18 | - */ |
|
| 19 | - public $data; |
|
| 16 | + /** |
|
| 17 | + * @var array|IdiormResultSet |
|
| 18 | + */ |
|
| 19 | + public $data; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param $idiormDbal |
|
| 23 | - * @param int $perPage |
|
| 24 | - * @param int $page |
|
| 25 | - * @throws DatabaseException |
|
| 26 | - */ |
|
| 27 | - public function __construct($idiormDbal, int $perPage, int $page = 1) |
|
| 28 | - { |
|
| 29 | - /** @var IdiormDbal $idiormDbal */ |
|
| 30 | - $this->total = $idiormDbal->getOrmModel()->count(); |
|
| 31 | - $this->dbal = $idiormDbal; |
|
| 32 | - $this->dbal->limit($perPage)->offset($perPage * ($page - 1)); |
|
| 33 | - $this->data = $this->dbal->getOrmModel()->find_many(); |
|
| 34 | - $this->perPage = $perPage; |
|
| 35 | - $this->page = $page; |
|
| 36 | - $this->baseUrl = base_dir(); |
|
| 37 | - } |
|
| 21 | + /** |
|
| 22 | + * @param $idiormDbal |
|
| 23 | + * @param int $perPage |
|
| 24 | + * @param int $page |
|
| 25 | + * @throws DatabaseException |
|
| 26 | + */ |
|
| 27 | + public function __construct($idiormDbal, int $perPage, int $page = 1) |
|
| 28 | + { |
|
| 29 | + /** @var IdiormDbal $idiormDbal */ |
|
| 30 | + $this->total = $idiormDbal->getOrmModel()->count(); |
|
| 31 | + $this->dbal = $idiormDbal; |
|
| 32 | + $this->dbal->limit($perPage)->offset($perPage * ($page - 1)); |
|
| 33 | + $this->data = $this->dbal->getOrmModel()->find_many(); |
|
| 34 | + $this->perPage = $perPage; |
|
| 35 | + $this->page = $page; |
|
| 36 | + $this->baseUrl = base_dir(); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return mixed |
|
| 41 | - */ |
|
| 42 | - public function firstItem() |
|
| 43 | - { |
|
| 44 | - if (!is_array($this->data)){ |
|
| 45 | - $this->data = $this->data->as_array(); |
|
| 46 | - } |
|
| 47 | - return $this->data[array_key_first($this->data)]; |
|
| 48 | - } |
|
| 39 | + /** |
|
| 40 | + * @return mixed |
|
| 41 | + */ |
|
| 42 | + public function firstItem() |
|
| 43 | + { |
|
| 44 | + if (!is_array($this->data)){ |
|
| 45 | + $this->data = $this->data->as_array(); |
|
| 46 | + } |
|
| 47 | + return $this->data[array_key_first($this->data)]; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @return mixed |
|
| 52 | - */ |
|
| 53 | - public function lastItem() |
|
| 54 | - { |
|
| 55 | - if (!is_array($this->data)){ |
|
| 56 | - $this->data = $this->data->as_array(); |
|
| 57 | - } |
|
| 58 | - return $this->data[array_key_last($this->data)]; |
|
| 59 | - } |
|
| 50 | + /** |
|
| 51 | + * @return mixed |
|
| 52 | + */ |
|
| 53 | + public function lastItem() |
|
| 54 | + { |
|
| 55 | + if (!is_array($this->data)){ |
|
| 56 | + $this->data = $this->data->as_array(); |
|
| 57 | + } |
|
| 58 | + return $this->data[array_key_last($this->data)]; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return array |
|
| 63 | - */ |
|
| 64 | - public function data() |
|
| 65 | - { |
|
| 66 | - if (!empty($this->data) && !is_array($this->data)){ |
|
| 67 | - $this->data = $this->data->as_array(); |
|
| 68 | - } |
|
| 69 | - return $this->data ?? []; |
|
| 70 | - } |
|
| 61 | + /** |
|
| 62 | + * @return array |
|
| 63 | + */ |
|
| 64 | + public function data() |
|
| 65 | + { |
|
| 66 | + if (!empty($this->data) && !is_array($this->data)){ |
|
| 67 | + $this->data = $this->data->as_array(); |
|
| 68 | + } |
|
| 69 | + return $this->data ?? []; |
|
| 70 | + } |
|
| 71 | 71 | } |
| 72 | 72 | \ No newline at end of file |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | public function firstItem() |
| 43 | 43 | { |
| 44 | - if (!is_array($this->data)){ |
|
| 44 | + if (!is_array($this->data)) { |
|
| 45 | 45 | $this->data = $this->data->as_array(); |
| 46 | 46 | } |
| 47 | 47 | return $this->data[array_key_first($this->data)]; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function lastItem() |
| 54 | 54 | { |
| 55 | - if (!is_array($this->data)){ |
|
| 55 | + if (!is_array($this->data)) { |
|
| 56 | 56 | $this->data = $this->data->as_array(); |
| 57 | 57 | } |
| 58 | 58 | return $this->data[array_key_last($this->data)]; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | */ |
| 64 | 64 | public function data() |
| 65 | 65 | { |
| 66 | - if (!empty($this->data) && !is_array($this->data)){ |
|
| 66 | + if (!empty($this->data) && !is_array($this->data)) { |
|
| 67 | 67 | $this->data = $this->data->as_array(); |
| 68 | 68 | } |
| 69 | 69 | return $this->data ?? []; |