Total Complexity | 4 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
12 | class UserController |
||
13 | { |
||
14 | private const PAGINATION_INDEX = 5; |
||
15 | |||
16 | private ViewRenderer $viewRenderer; |
||
17 | |||
18 | public function __construct(ViewRenderer $viewRenderer) |
||
19 | { |
||
20 | $this->viewRenderer = $viewRenderer->withControllerName('user'); |
||
21 | } |
||
22 | |||
23 | public function index(Request $request, UserRepository $userRepository): Response |
||
24 | { |
||
25 | $pageNum = (int)$request->getAttribute('page', 1); |
||
26 | |||
27 | $dataReader = $userRepository->findAll()->withSort((new Sort([]))->withOrderString('login')); |
||
28 | $paginator = (new OffsetPaginator($dataReader)) |
||
29 | ->withPageSize(self::PAGINATION_INDEX) |
||
30 | ->withCurrentPage($pageNum); |
||
31 | |||
32 | return $this->viewRenderer->render('index', ['paginator' => $paginator]); |
||
33 | } |
||
34 | |||
35 | public function profile(Request $request, UserRepository $userRepository): Response |
||
44 | } |
||
45 | } |
||
46 |