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.

AbstractSegmentedRepresentation   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 92
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
A getLimit() 0 4 1
A getParameters() 0 8 2
A getTotal() 0 4 1
A getLimitParameterName() 0 4 1
A moveParameterToEnd() 0 10 2
1
<?php
2
3
namespace Hateoas\Representation;
4
5
use Hateoas\Configuration\Annotation as Hateoas;
6
use JMS\Serializer\Annotation as Serializer;
7
8
/**
9
 * @Serializer\ExclusionPolicy("all")
10
 *
11
 * @author Premi Giorgio <[email protected]>
12
 */
13
abstract class AbstractSegmentedRepresentation extends RouteAwareRepresentation
14
{
15
    /**
16
     * @var int
17
     *
18
     * @Serializer\Expose
19
     * @Serializer\Type("integer")
20
     * @Serializer\XmlAttribute
21
     */
22
    private $limit;
23
24
    /**
25
     * @var int
26
     *
27
     * @Serializer\Expose
28
     * @Serializer\Type("integer")
29
     * @Serializer\XmlAttribute
30
     */
31
    private $total;
32
33
    /**
34
     * @var string
35
     */
36
    private $limitParameterName;
37
38
    public function __construct(
39
        $inline,
40
        $route,
41
        array $parameters        = array(),
42
        $limit,
43
        $total                   = null,
44
        $limitParameterName      = null,
45
        $absolute                = false
46
    ) {
47
        parent::__construct($inline, $route, $parameters, $absolute);
48
49
        $this->total               = $total;
50
        $this->limit               = $limit;
51
        $this->limitParameterName  = $limitParameterName ?: 'limit';
52
    }
53
54
    /**
55
     * @return int
56
     */
57
    public function getLimit()
58
    {
59
        return $this->limit;
60
    }
61
62
    /**
63
     * @param  null  $limit
64
     * @return array
65
     */
66
    public function getParameters($limit = null)
67
    {
68
        $parameters = parent::getParameters();
69
70
        $parameters[$this->limitParameterName] = null === $limit ? $this->getLimit() : $limit;
71
72
        return $parameters;
73
    }
74
75
    /**
76
     * @return int
77
     */
78
    public function getTotal()
79
    {
80
        return $this->total;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function getLimitParameterName()
87
    {
88
        return $this->limitParameterName;
89
    }
90
91
    /**
92
     * @param string $key
93
     */
94
    protected function moveParameterToEnd(array &$parameters, $key)
95
    {
96
        if (! array_key_exists($key, $parameters)) {
97
            return;
98
        }
99
100
        $value = $parameters[$key];
101
        unset($parameters[$key]);
102
        $parameters[$key] = $value;
103
    }
104
}
105