Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public function getPageInfo() |
||
30 | { |
||
31 | $query = clone $this->query; |
||
32 | $query->resetOrderBy(); |
||
33 | $query->resetLimit(); |
||
34 | $query->resetColumns(); |
||
35 | $query->columns('COUNT(*)'); |
||
36 | |||
37 | $statement = $query->perform(); |
||
38 | $statement->setFetchMode(PDO::FETCH_NUM); |
||
39 | |||
40 | $page = $this->page; |
||
41 | $count = $statement->fetch(); |
||
42 | $count = intval($count[0]); |
||
43 | |||
44 | return [ |
||
45 | 'total' => $count, |
||
46 | 'page' => $page, |
||
47 | 'previous' => $page > 1 ? $page - 1 : null, |
||
48 | 'next' => $count > ($page * $this->perPage) ? $page + 1 : null, |
||
49 | ]; |
||
50 | } |
||
51 | } |
||
52 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: