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
Push — feature/move_paginate_function... ( 67f724 )
by Alessandro
02:48
created

Pager::setPagerAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Mado\QueryBundle\Services;
4
5
use Doctrine\ORM\QueryBuilder;
6
use Hateoas\Representation\Factory\PagerfantaFactory;
7
use Mado\QueryBundle\Objects\PagerAdapter;
8
use Mado\QueryBundle\Objects\PagerfantaBuilder;
9
use Mado\QueryBundle\Queries\QueryBuilderOptions;
10
11
class Pager
12
{
13
    private const LIMIT = 10;
14
15
    private const PAGE = 1;
16
17
    private const LIFETIME = 600;
18
19
    private $pagerFactory;
20
21
    private $router;
22
23
    private $pagerAdapter;
24
25
    private $pagerfantaBuilder;
26
27 2
    public function __construct()
28
    {
29 2
        $this->setPaferfantaFactory(new PagerfantaFactory());
30 2
        $this->setRouter(new Router());
31 2
        $this->setPagerAdapter(new PagerAdapter());
32 2
        $this->setPagerfantaBuilder(new PagerfantaBuilder());
33 2
    }
34
35 2
    public function setPaferfantaFactory(PagerfantaFactory $pagerFactory)
36
    {
37 2
        $this->pagerFactory = $pagerFactory;
38 2
    }
39
40 2
    public function setRouter(Router $router)
41
    {
42 2
        $this->router = $router;
43 2
    }
44
45 2
    public function setPagerAdapter($pagerAdapter)
46
    {
47 2
        $this->pagerAdapter = $pagerAdapter;
48 2
    }
49
50 2
    public function setPagerfantaBuilder(PagerfantaBuilder $pagerfantaBuilder)
51
    {
52 2
        $this->pagerfantaBuilder = $pagerfantaBuilder;
53 2
    }
54
55 2
    public function paginateResults (
56
        QueryBuilder $queryBuilder,
57
        QueryBuilderOptions $queryOptions,
58
        $routeName,
59
        $useResultCache
60
    ) {
61 2
        $limit = $queryOptions->get('limit', self::LIMIT);
62 2
        $page = $queryOptions->get('page', self::PAGE);
63
64 2
        $this->pagerAdapter->initPagerAdapter($queryBuilder);
65
66 2
        $query = $this->pagerAdapter->getQuery();
67 2
        if (isset($useResultCache) && $useResultCache) {
68 1
            $query->useResultCache(true, self::LIFETIME);
69
        }
70
71 2
        $pager = $this->pagerfantaBuilder->create(
72 2
            $this->pagerAdapter->getAdapter(),
73 2
            $limit,
74 2
            $page
75
        );
76 2
        $route = $this->router->createRouter($queryOptions, $routeName);
77
78 2
        return $this->pagerFactory->createRepresentation($pager, $route);
79
    }
80
}