| Total Complexity | 4 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | abstract class BaseRepository |
||
| 8 | { |
||
| 9 | public function __construct(protected \PDO $database) |
||
| 10 | { |
||
| 11 | 56 | } |
|
| 12 | |||
| 13 | 56 | protected function getDb(): \PDO |
|
| 14 | 56 | { |
|
| 15 | return $this->database; |
||
| 16 | 39 | } |
|
| 17 | |||
| 18 | 39 | protected function getResultsWithPagination( |
|
| 19 | string $query, |
||
| 20 | int $page, |
||
| 21 | 4 | int $perPage, |
|
| 22 | array $params, |
||
| 23 | int $total |
||
| 24 | ): array { |
||
| 25 | return [ |
||
| 26 | 'pagination' => [ |
||
| 27 | 'totalRows' => $total, |
||
| 28 | 'totalPages' => ceil($total / $perPage), |
||
| 29 | 'currentPage' => $page, |
||
| 30 | 4 | 'perPage' => $perPage, |
|
| 31 | 4 | ], |
|
| 32 | 4 | 'data' => $this->getResultByPage($query, $page, $perPage, $params), |
|
| 33 | 4 | ]; |
|
| 34 | } |
||
| 35 | 4 | ||
| 36 | /** |
||
| 37 | * @param array<string> $params |
||
| 38 | * @return array<float|int|string> |
||
| 39 | 4 | */ |
|
| 40 | protected function getResultByPage( |
||
| 52 | } |
||
| 53 | } |
||
| 54 |