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.
Completed
Pull Request — master (#225)
by
unknown
11:59
created

KnpPaginatorFactory::getLimitParameterName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
namespace Hateoas\Representation\Factory;
3
4
use Hateoas\Configuration\Route;
5
use Hateoas\Representation\CollectionRepresentation;
6
use Hateoas\Representation\PaginatedRepresentation;
7
use Knp\Component\Pager\Pagination\SlidingPagination;
8
9 View Code Duplication
class KnpPaginatorFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    /**
12
     * @var
13
     */
14
    private $pageParameterName;
15
16
    /**
17
     * @var
18
     */
19
    private $limitParameterName;
20
21
22
    /**
23
     * @param string $pageParameterName
24
     * @param string $limitParameterName
25
     */
26
    public function __construct($pageParameterName = null, $limitParameterName = null)
27
    {
28
        $this->pageParameterName  = $pageParameterName;
29
        $this->limitParameterName = $limitParameterName;
30
    }
31
32
    /**
33
     * @param SlidingPagination $slidingPagination
34
     * @param Route $route
35
     * @param null $inline
36
     * @return PaginatedRepresentation
37
     */
38
    public function createRepresentation(SlidingPagination $slidingPagination, Route $route, $inline = null)
39
    {
40
        if (null === $inline) {
41
            $inline = new CollectionRepresentation($slidingPagination->getItems());
42
        }
43
44
        return new PaginatedRepresentation(
45
            $inline,
46
            $route->getName(),
47
            $route->getParameters(),
0 ignored issues
show
Bug introduced by
It seems like $route->getParameters() targeting Hateoas\Configuration\Route::getParameters() can also be of type string; however, Hateoas\Representation\P...entation::__construct() does only seem to accept array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
48
            $slidingPagination->getCurrentPageNumber(),
49
            $slidingPagination->getItemNumberPerPage(),
50
            $slidingPagination->getPaginationData()['pageCount'],
51
            $this->getPageParameterName(),
52
            $this->getLimitParameterName(),
53
            $route->isAbsolute(),
54
            $slidingPagination->getTotalItemCount()
55
        );
56
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getPageParameterName()
63
    {
64
        return $this->pageParameterName;
65
    }
66
67
    /**
68
     * @return string
69
     */
70
    public function getLimitParameterName()
71
    {
72
        return $this->limitParameterName;
73
    }
74
75
}