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.

Pager::paginateResults()   A
last analyzed

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