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   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 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
}