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.

CollectionRepresentation::setRel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Hateoas\Representation;
4
5
use Hateoas\Configuration\Annotation as Hateoas;
6
use Hateoas\Configuration\Embedded;
7
use Hateoas\Configuration\Exclusion;
8
use Hateoas\Configuration\Metadata\ClassMetadataInterface;
9
use Hateoas\Configuration\Relation;
10
use JMS\Serializer\Annotation as Serializer;
11
12
/**
13
 * @Serializer\ExclusionPolicy("all")
14
 * @Serializer\XmlRoot("collection")
15
 *
16
 * @Hateoas\RelationProvider("getRelations")
17
 *
18
 * @author Adrien Brault <[email protected]>
19
 */
20
class CollectionRepresentation
21
{
22
    /**
23
     * @var string
24
     */
25
    private $rel;
26
27
    /**
28
     * @var mixed
29
     */
30
    private $resources;
31
32
    /**
33
     * @var null|string
34
     */
35
    private $xmlElementName;
36
37
    /**
38
     * @var null|Exclusion
39
     */
40
    private $exclusion;
41
42
    /**
43
     * @var null|Exclusion
44
     */
45
    private $embedExclusion;
46
47
    /**
48
     * @var array
49
     */
50
    private $relations;
51
52
    /**
53
     * @param string $rel
54
     * @param string $xmlElementName
55
     */
56
    public function __construct(
57
        $resources,
58
        $rel                      = null,
59
        $xmlElementName           = null,
60
        Exclusion $exclusion      = null,
61
        Exclusion $embedExclusion = null,
62
        array $relations          = array()
63
    ) {
64
        if ($resources instanceof \Traversable) {
65
            $resources = iterator_to_array($resources);
66
        }
67
68
        $this->resources      = $resources;
69
        $this->rel            = $rel ?: 'items';
70
        $this->xmlElementName = $xmlElementName;
71
        $this->exclusion      = $exclusion;
72
        $this->embedExclusion = $embedExclusion;
73
        $this->relations      = $relations;
74
    }
75
76
    /**
77
     * @return string
78
     */
79
    public function getRel()
80
    {
81
        return $this->rel;
82
    }
83
84
    /**
85
     * @param string $rel
86
     */
87
    public function setRel($rel)
88
    {
89
        $this->rel = $rel;
90
    }
91
92
    /**
93
     * @return mixed
94
     */
95
    public function getResources()
96
    {
97
        return $this->resources;
98
    }
99
100
    /**
101
     * @return null|string
102
     */
103
    public function getXmlElementName()
104
    {
105
        return $this->xmlElementName;
106
    }
107
108
    /**
109
     * @param null|string $xmlElementName
110
     */
111
    public function setXmlElementName($xmlElementName)
112
    {
113
        $this->xmlElementName = $xmlElementName;
114
    }
115
116
    public function getRelations($object, ClassMetadataInterface $classMetadata)
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $classMetadata is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
117
    {
118
        return array_merge(array(
119
            new Relation(
120
                $this->rel,
121
                null,
122
                new Embedded(
123
                    'expr(object.getResources())',
124
                    $this->xmlElementName,
125
                    $this->embedExclusion
126
                ),
127
                array(),
128
                $this->exclusion
129
            )
130
        ), $this->relations);
131
    }
132
}
133