GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — 2.4 (#141)
by Alessandro
08:47 queued 02:39
created

Pager::paginateResults()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 18
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
ccs 8
cts 8
cp 1
cc 3
eloc 7
nc 2
nop 5
crap 3
1
<?php
2
3
namespace Mado\QueryBundle\Services;
4
5
use Hateoas\Representation\Factory\PagerfantaFactory;
6
use Mado\QueryBundle\Objects\PagerfantaBuilder;
7
use Mado\QueryBundle\Queries\QueryBuilderOptions;
8
use Pagerfanta\Adapter\DoctrineORMAdapter;
9
10
class Pager
11
{
12
    private const LIMIT = 10;
13
14
    private const PAGE = 1;
15
16
    private const LIFETIME = 600;
17
18
    private $router;
19
20 2
    public function __construct()
21
    {
22 2
        $this->setRouter(new Router());
23 2
    }
24
25 2
    public function setRouter(Router $router)
26
    {
27 2
        $this->router = $router;
28 2
    }
29
30 2
    public function paginateResults (
31
        QueryBuilderOptions $queryOptions,
32
        DoctrineORMAdapter $ormAdapter,
33
        PagerfantaBuilder $pagerfantaBuilder,
34
        $routeName,
35
        $useResultCache
36
    ) {
37 2
        $limit = $queryOptions->get('limit', self::LIMIT);
38 2
        $page = $queryOptions->get('page', self::PAGE);
39
40 2
        $query = $ormAdapter->getQuery();
41 2
        if (isset($useResultCache) && $useResultCache) {
42 1
            $query->useResultCache(true, self::LIFETIME);
43
        }
44
45 2
        $route = $this->router->createRouter($queryOptions, $routeName);
46
47 2
        return $pagerfantaBuilder->createRepresentation($route, $limit, $page);
48
    }
49
}