Completed
Push — standalone ( a7b79f...57bbfc )
by Philip
02:45
created

PropertyMetadata::isPuttable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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 Right|null
72
     */
73
    private $subResourcePutRight;
74
75
    /**
76
     * @var Right|null
77
     */
78
    private $subResourceDeleteRight;
79
80
    /**
81
     * @var string|null
82
     */
83
    private $targetClass;
84
85
    /**
86
     * @return boolean
87
     */
88
    public function isPuttable()
89
    {
90
        return $this->puttable;
91
    }
92
93
    /**
94
     * @param boolean $puttable
95
     */
96 22
    public function setPuttable($puttable)
97
    {
98 22
        $this->puttable = $puttable;
99 22
    }
100
101
    /**
102
     * @return boolean
103
     */
104
    public function isPostable()
105
    {
106
        return $this->postable;
107
    }
108
109
    /**
110
     * @param boolean $postable
111
     */
112
    public function setPostable($postable)
113
    {
114
        $this->postable = $postable;
115
    }
116
117
    /**
118
     * @return boolean
119
     */
120 4
    public function isIncludable()
121
    {
122 4
        return $this->includable;
123
    }
124
125
    /**
126
     * @param boolean $includable
127
     */
128 22
    public function setIncludable($includable)
129
    {
130 22
        $this->includable = $includable;
131 22
    }
132
133
    /**
134
     * @return boolean
135
     */
136 24
    public function isSubResource()
137
    {
138 24
        return $this->subResource;
139
    }
140
141
    /**
142
     * @param boolean $subResource
143
     */
144 22
    public function setSubResource($subResource)
145
    {
146 22
        $this->subResource = $subResource;
147 22
    }
148
149
    /**
150
     * @return Right|null
151
     */
152
    public function getSubResourceListRight()
153
    {
154
        return $this->subResourceListRight;
155
    }
156
157
    /**
158
     * @param Right|null $subResourceListRight
159
     */
160
    public function setSubResourceListRight($subResourceListRight)
161
    {
162
        $this->subResourceListRight = $subResourceListRight;
163
    }
164
165
    /**
166
     * @return Right|null
167
     */
168 22
    public function getSubResourcePostRight()
169
    {
170 22
        return $this->subResourcePostRight;
171
    }
172
173
    /**
174
     * @param Right|null $subResourcePostRight
175
     */
176
    public function setSubResourcePostRight($subResourcePostRight)
177
    {
178
        $this->subResourcePostRight = $subResourcePostRight;
179
    }
180
181
    /**
182
     * @param Right|null $subResourcePutRight
183
     */
184 22
    public function setSubResourcePutRight($subResourcePutRight)
185
    {
186 22
        $this->subResourcePutRight = $subResourcePutRight;
187 22
    }
188
189
    /**
190
     * @return Right|null
191
     */
192 22
    public function getSubResourcePutRight()
193
    {
194 22
        return $this->subResourcePutRight;
195
    }
196
197
    /**
198
     * @param Right|null $subResourceDeleteRight
199
     */
200 22
    public function setSubResourceDeleteRight($subResourceDeleteRight)
201
    {
202 22
        $this->subResourceDeleteRight = $subResourceDeleteRight;
203 22
    }
204
205
    /**
206
     * @return Right|null
207
     */
208 22
    public function getSubResourceDeleteRight()
209
    {
210 22
        return $this->subResourceDeleteRight;
211
    }
212
213
    /**
214
     * @return null|string
215
     */
216
    public function getTargetClass()
217
    {
218
        return $this->targetClass;
219
    }
220
221
    /**
222
     * @param null|string $targetClass
223
     */
224 22
    public function setTargetClass($targetClass)
225
    {
226 22
        $this->targetClass = $targetClass;
227 22
    }
228
229
    /**
230
     * @return null|string
231
     */
232 22
    public function getSubResourcePath()
233
    {
234 22
        return $this->subResourcePath;
235
    }
236
237
    /**
238
     * @param null|string $subResourcePath
239
     */
240
    public function setSubResourcePath($subResourcePath)
241
    {
242
        $this->subResourcePath = $subResourcePath;
243
    }
244
245
    /**
246
     * @return bool
247
     */
248 4
    public function isExcluded(): bool
249
    {
250 4
        return $this->excluded;
251
    }
252
253
    /**
254
     * @param bool $excluded
255
     */
256 22
    public function setExcluded(bool $excluded)
257
    {
258 22
        $this->excluded = $excluded;
259 22
    }
260
261
    /**
262
     * @return null|\string[]
263
     */
264
    public function getIncludablePaths(): ?array
265
    {
266
        return $this->includablePaths;
267
    }
268
269
    /**
270
     * @param null|\string[] $includablePaths
271
     */
272 22
    public function setIncludablePaths(?array $includablePaths)
273
    {
274 22
        $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...
275 22
    }
276
277
    /**
278
     * @return bool
279
     */
280 4
    public function isAssociation(): bool
281
    {
282 4
        return $this->association;
283
    }
284
285
    /**
286
     * @param bool $association
287
     */
288 22
    public function setAssociation(bool $association)
289
    {
290 22
        $this->association = $association;
291 22
    }
292
293
    /**
294
     * @return bool
295
     */
296
    public function isCollection(): bool
297
    {
298
        return $this->collection;
299
    }
300
301
    /**
302
     * @param bool $collection
303
     */
304 22
    public function setCollection(bool $collection)
305
    {
306 22
        $this->collection = $collection;
307 22
    }
308
309 4
    public function getType(): ?string
310
    {
311 4
        return $this->type;
312
    }
313
314 32
    public function setType(?string $type)
315
    {
316 32
        $this->type = $type;
317 32
    }
318
}
319