Completed
Push — standalone ( 57bbfc...ea253f )
by Philip
03:00
created

PropertyMetadata   A

Complexity

Total Complexity 30

Size/Duplication

Total Lines 311
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 78.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 30
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 311
ccs 59
cts 75
cp 0.7867
rs 10

30 Methods

Rating   Name   Duplication   Size   Complexity  
A isPuttable() 0 4 1
A setPuttable() 0 4 1
A isPostable() 0 4 1
A setPostable() 0 4 1
A isIncludable() 0 4 1
A setIncludable() 0 4 1
A isSubResource() 0 4 1
A setSubResource() 0 4 1
A getSubResourceListRight() 0 4 1
A setSubResourceListRight() 0 4 1
A getSubResourcePostRight() 0 4 1
A setSubResourcePostRight() 0 4 1
A setSubResourcePutRight() 0 4 1
A getSubResourcePutRight() 0 4 1
A setSubResourceDeleteRight() 0 4 1
A getSubResourceDeleteRight() 0 4 1
A getTargetClass() 0 4 1
A setTargetClass() 0 4 1
A getSubResourcePath() 0 4 1
A setSubResourcePath() 0 4 1
A isExcluded() 0 4 1
A setExcluded() 0 4 1
A getIncludablePaths() 0 4 1
A setIncludablePaths() 0 4 1
A isAssociation() 0 4 1
A setAssociation() 0 4 1
A isCollection() 0 4 1
A setCollection() 0 4 1
A getType() 0 4 1
A setType() 0 4 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 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 2
    public function isPuttable()
89
    {
90 2
        return $this->puttable;
91
    }
92
93
    /**
94
     * @param boolean $puttable
95
     */
96 20
    public function setPuttable($puttable)
97
    {
98 20
        $this->puttable = $puttable;
99 20
    }
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 20
    public function isIncludable()
121
    {
122 20
        return $this->includable;
123
    }
124
125
    /**
126
     * @param boolean $includable
127
     */
128 20
    public function setIncludable($includable)
129
    {
130 20
        $this->includable = $includable;
131 20
    }
132
133
    /**
134
     * @return boolean
135
     */
136 4
    public function isSubResource()
137
    {
138 4
        return $this->subResource;
139
    }
140
141
    /**
142
     * @param boolean $subResource
143
     */
144 20
    public function setSubResource($subResource)
145
    {
146 20
        $this->subResource = $subResource;
147 20
    }
148
149
    /**
150
     * @return Right|null
151
     */
152 6
    public function getSubResourceListRight()
153
    {
154 6
        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 2
    public function getSubResourcePostRight()
169
    {
170 2
        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 20
    public function setSubResourcePutRight($subResourcePutRight)
185
    {
186 20
        $this->subResourcePutRight = $subResourcePutRight;
187 20
    }
188
189
    /**
190
     * @return Right|null
191
     */
192 4
    public function getSubResourcePutRight()
193
    {
194 4
        return $this->subResourcePutRight;
195
    }
196
197
    /**
198
     * @param Right|null $subResourceDeleteRight
199
     */
200 20
    public function setSubResourceDeleteRight($subResourceDeleteRight)
201
    {
202 20
        $this->subResourceDeleteRight = $subResourceDeleteRight;
203 20
    }
204
205
    /**
206
     * @return Right|null
207
     */
208 4
    public function getSubResourceDeleteRight()
209
    {
210 4
        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 2
    public function getSubResourcePath()
233
    {
234 2
        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 20
    public function isExcluded(): bool
249
    {
250 20
        return $this->excluded;
251
    }
252
253
    /**
254
     * @param bool $excluded
255
     */
256 20
    public function setExcluded(bool $excluded)
257
    {
258 20
        $this->excluded = $excluded;
259 20
    }
260
261
    /**
262
     * @return null|\string[]
263
     */
264 8
    public function getIncludablePaths(): ?array
265
    {
266 8
        return $this->includablePaths;
267
    }
268
269
    /**
270
     * @param null|\string[] $includablePaths
271
     */
272 20
    public function setIncludablePaths(?array $includablePaths)
273
    {
274 20
        $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 20
    }
276
277
    /**
278
     * @return bool
279
     */
280 20
    public function isAssociation(): bool
281
    {
282 20
        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 2
    public function isCollection(): bool
297
    {
298 2
        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 20
    public function getType(): ?string
310
    {
311 20
        return $this->type;
312
    }
313
314 32
    public function setType(?string $type)
315
    {
316 32
        $this->type = $type;
317 32
    }
318
}
319