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

PagerfantaBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A createRepresentation() 0 8 1
A __construct() 0 4 1
1
<?php
2
3
namespace Mado\QueryBundle\Objects;
4
5
use Hateoas\Representation\Factory\PagerfantaFactory;
6
use Pagerfanta\Adapter\DoctrineORMAdapter;
7
use Pagerfanta\Pagerfanta;
8
9
class PagerfantaBuilder
10
{
11
    private $pagerfantaFactory;
12
13
    private $ormAdapter;
14
15
    public function __construct(PagerfantaFactory $pagerfantaFactory, DoctrineORMAdapter $ormAdapter)
16
    {
17
        $this->pagerfantaFactory = $pagerfantaFactory;
18
        $this->ormAdapter = $ormAdapter;
19
    }
20
21
    public function create($limit, $page) :Pagerfanta
22
    {
23
        $pager = new Pagerfanta($this->ormAdapter);
24
        $pager->setNormalizeOutOfRangePages(true);
25
        $pager->setMaxPerPage($limit);
26
        $pager->setCurrentPage($page);
27
28
        return $pager;
29
    }
30
31
    public function createRepresentation($route, $limit, $page)
32
    {
33
        $pager = $this->create(
34
            $limit,
35
            $page
36
        );
37
38
        return $this->pagerfantaFactory->createRepresentation($pager, $route);
39
    }
40
}
41