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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 14
dl 0
loc 38
c 0
b 0
f 0
ccs 14
cts 14
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setRouter() 0 3 1
A paginateResults() 0 18 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