Conditions | 4 |
Paths | 3 |
Total Lines | 17 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 4.0312 |
Changes | 0 |
1 | <?php |
||
32 | 3 | public function createPaginator(string $parameter, int $limit = 25): PaginatorInterface |
|
33 | { |
||
34 | 3 | if (!$this->container->has(ServerRequestInterface::class)) { |
|
35 | throw new ScopeException('Unable to create paginator, no request scope found'); |
||
36 | } |
||
37 | /** |
||
38 | * @var array $query |
||
39 | */ |
||
40 | 3 | $query = $this->container->get(ServerRequestInterface::class)->getQueryParams(); |
|
41 | |||
42 | //Getting page number |
||
43 | 2 | $page = 0; |
|
44 | 2 | if (!empty($query[$parameter]) && \is_scalar($query[$parameter])) { |
|
45 | 1 | $page = (int)$query[$parameter]; |
|
46 | } |
||
47 | |||
48 | 2 | return $this->factory->make(Paginator::class, ['limit' => $limit, 'parameter' => $parameter])->withPage($page); |
|
49 | } |
||
51 |