Completed
Push — standalone ( 7c3a2c...83bb11 )
by Philip
05:16
created

PropertyMetadata::setTargetClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Dontdrinkandroot\RestBundle\Metadata;
4
5
use Dontdrinkandroot\RestBundle\Metadata\Annotation\Right;
6
use Metadata\PropertyMetadata as BasePropertyMetadata;
7
8
class PropertyMetadata extends BasePropertyMetadata
9
{
10
    /**
11
     * @var string|null
12
     */
13
    private $type;
14
15
    /**
16
     * @var bool
17
     */
18
    private $puttable = false;
19
20
    /**
21
     * @var bool
22
     */
23
    private $excluded = false;
24
25
    /**
26
     * @var bool
27
     */
28
    private $postable = false;
29
30
    /**
31
     * @var bool
32
     */
33
    private $includable = false;
34
35
    /**
36
     * @var string[]|null
37
     */
38
    private $includablePaths;
39
40
    /**
41
     * @var bool
42
     */
43
    private $subResource = false;
44
45
    /**
46
     * @var bool
47
     */
48
    private $association = false;
49
50
    /**
51
     * @var bool
52
     */
53
    private $collection = false;
54
55
    /**
56
     * @var string|null
57
     */
58
    private $subResourcePath;
59
60
    /**
61
     * @var Right|null
62
     */
63
    private $subResourceListRight;
64
65
    /**
66
     * @var Right|null
67
     */
68
    private $subResourcePostRight;
69
70
    /**
71
     * @var string|null
72
     */
73
    private $targetClass;
74
75
    /**
76
     * @return boolean
77
     */
78 2
    public function isPuttable()
79
    {
80 2
        return $this->puttable;
81
    }
82
83
    /**
84
     * @param boolean $puttable
85
     */
86 12
    public function setPuttable($puttable)
87
    {
88 12
        $this->puttable = $puttable;
89 12
    }
90
91
    /**
92
     * @return boolean
93
     */
94
    public function isPostable()
95
    {
96
        return $this->postable;
97
    }
98
99
    /**
100
     * @param boolean $postable
101
     */
102
    public function setPostable($postable)
103
    {
104
        $this->postable = $postable;
105
    }
106
107
    /**
108
     * @return boolean
109
     */
110 10
    public function isIncludable()
111
    {
112 10
        return $this->includable;
113
    }
114
115
    /**
116
     * @param boolean $includable
117
     */
118
    public function setIncludable($includable)
119
    {
120
        $this->includable = $includable;
121
    }
122
123
    /**
124
     * @return boolean
125
     */
126 4
    public function isSubResource()
127
    {
128 4
        return $this->subResource;
129
    }
130
131
    /**
132
     * @param boolean $subResource
133
     */
134
    public function setSubResource($subResource)
135
    {
136
        $this->subResource = $subResource;
137
    }
138
139
    /**
140
     * @return Right|null
141
     */
142
    public function getSubResourceListRight()
143
    {
144
        return $this->subResourceListRight;
145
    }
146
147
    /**
148
     * @param Right|null $subResourceListRight
149
     */
150
    public function setSubResourceListRight($subResourceListRight)
151
    {
152
        $this->subResourceListRight = $subResourceListRight;
153
    }
154
155
    /**
156
     * @return Right|null
157
     */
158
    public function getSubResourcePostRight()
159
    {
160
        return $this->subResourcePostRight;
161
    }
162
163
    /**
164
     * @param Right|null $subResourcePostRight
165
     */
166
    public function setSubResourcePostRight($subResourcePostRight)
167
    {
168
        $this->subResourcePostRight = $subResourcePostRight;
169
    }
170
171
    /**
172
     * @return null|string
173
     */
174
    public function getTargetClass()
175
    {
176
        return $this->targetClass;
177
    }
178
179
    /**
180
     * @param null|string $targetClass
181
     */
182 2
    public function setTargetClass($targetClass)
183
    {
184 2
        $this->targetClass = $targetClass;
185 2
    }
186
187
    /**
188
     * @return null|string
189
     */
190
    public function getSubResourcePath()
191
    {
192
        return $this->subResourcePath;
193
    }
194
195
    /**
196
     * @param null|string $subResourcePath
197
     */
198
    public function setSubResourcePath($subResourcePath)
199
    {
200
        $this->subResourcePath = $subResourcePath;
201
    }
202
203
    /**
204
     * @return bool
205
     */
206 10
    public function isExcluded(): bool
207
    {
208 10
        return $this->excluded;
209
    }
210
211
    /**
212
     * @param bool $excluded
213
     */
214 12
    public function setExcluded(bool $excluded)
215
    {
216 12
        $this->excluded = $excluded;
217 12
    }
218
219
    /**
220
     * @return null|\string[]
221
     */
222
    public function getIncludablePaths(): ?array
223
    {
224
        return $this->includablePaths;
225
    }
226
227
    /**
228
     * @param null|\string[] $includablePaths
229
     */
230
    public function setIncludablePaths(?array $includablePaths)
231
    {
232
        $this->includablePaths = $includablePaths;
0 ignored issues
show
Documentation Bug introduced by
It seems like $includablePaths can also be of type array<integer,object<string>>. However, the property $includablePaths is declared as type array<integer,string>|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
233
    }
234
235
    /**
236
     * @return bool
237
     */
238 10
    public function isAssociation(): bool
239
    {
240 10
        return $this->association;
241
    }
242
243
    /**
244
     * @param bool $association
245
     */
246 2
    public function setAssociation(bool $association)
247
    {
248 2
        $this->association = $association;
249 2
    }
250
251
    /**
252
     * @return bool
253
     */
254
    public function isCollection(): bool
255
    {
256
        return $this->collection;
257
    }
258
259
    /**
260
     * @param bool $collection
261
     */
262 2
    public function setCollection(bool $collection)
263
    {
264 2
        $this->collection = $collection;
265 2
    }
266
267 10
    public function getType(): ?string
268
    {
269 10
        return $this->type;
270
    }
271
272 22
    public function setType(?string $type)
273
    {
274 22
        $this->type = $type;
275 22
    }
276
}
277