Completed
Push — standalone ( 83bb11...ac8c4f )
by Philip
03:51
created

PropertyMetadata::isPostable()   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 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 16
    public function setPuttable($puttable)
87
    {
88 16
        $this->puttable = $puttable;
89 16
    }
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 14
    public function isIncludable()
111
    {
112 14
        return $this->includable;
113
    }
114
115
    /**
116
     * @param boolean $includable
117
     */
118 16
    public function setIncludable($includable)
119
    {
120 16
        $this->includable = $includable;
121 16
    }
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 16
    public function setSubResource($subResource)
135
    {
136 16
        $this->subResource = $subResource;
137 16
    }
138
139
    /**
140
     * @return Right|null
141
     */
142 2
    public function getSubResourceListRight()
143
    {
144 2
        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 2
    public function getSubResourcePostRight()
159
    {
160 2
        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 16
    public function setTargetClass($targetClass)
183
    {
184 16
        $this->targetClass = $targetClass;
185 16
    }
186
187
    /**
188
     * @return null|string
189
     */
190 2
    public function getSubResourcePath()
191
    {
192 2
        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 14
    public function isExcluded(): bool
207
    {
208 14
        return $this->excluded;
209
    }
210
211
    /**
212
     * @param bool $excluded
213
     */
214 16
    public function setExcluded(bool $excluded)
215
    {
216 16
        $this->excluded = $excluded;
217 16
    }
218
219
    /**
220
     * @return null|\string[]
221
     */
222 8
    public function getIncludablePaths(): ?array
223
    {
224 8
        return $this->includablePaths;
225
    }
226
227
    /**
228
     * @param null|\string[] $includablePaths
229
     */
230 16
    public function setIncludablePaths(?array $includablePaths)
231
    {
232 16
        $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 16
    }
234
235
    /**
236
     * @return bool
237
     */
238 14
    public function isAssociation(): bool
239
    {
240 14
        return $this->association;
241
    }
242
243
    /**
244
     * @param bool $association
245
     */
246 16
    public function setAssociation(bool $association)
247
    {
248 16
        $this->association = $association;
249 16
    }
250
251
    /**
252
     * @return bool
253
     */
254 2
    public function isCollection(): bool
255
    {
256 2
        return $this->collection;
257
    }
258
259
    /**
260
     * @param bool $collection
261
     */
262 16
    public function setCollection(bool $collection)
263
    {
264 16
        $this->collection = $collection;
265 16
    }
266
267 14
    public function getType(): ?string
268
    {
269 14
        return $this->type;
270
    }
271
272 26
    public function setType(?string $type)
273
    {
274 26
        $this->type = $type;
275 26
    }
276
}
277