This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php namespace BinPacking3d\Entity; |
||
2 | |||
3 | use BinPacking3d\Entity; |
||
4 | use BinPacking3d\EntityInterface; |
||
5 | use BinPacking3d\Utils; |
||
6 | |||
7 | /** |
||
8 | * Class Item |
||
9 | * @package BinPacking3d\Entity |
||
10 | */ |
||
11 | class Item implements EntityInterface |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * @var |
||
16 | */ |
||
17 | private $width; |
||
18 | |||
19 | /** |
||
20 | * @var |
||
21 | */ |
||
22 | private $height; |
||
23 | |||
24 | /** |
||
25 | * @var |
||
26 | */ |
||
27 | private $depth; |
||
28 | |||
29 | /** |
||
30 | * @var int |
||
31 | */ |
||
32 | private $quantity = 1; |
||
33 | |||
34 | /** |
||
35 | * @var bool |
||
36 | */ |
||
37 | private $verticalRotationLock = false; |
||
38 | |||
39 | /** |
||
40 | * @var |
||
41 | */ |
||
42 | private $itemIdentifier; |
||
43 | |||
44 | /** |
||
45 | * @var |
||
46 | */ |
||
47 | private $weight; |
||
48 | |||
49 | /** |
||
50 | * @var |
||
51 | */ |
||
52 | private $product; |
||
53 | |||
54 | /** |
||
55 | * @return array |
||
56 | */ |
||
57 | public function render() |
||
58 | { |
||
59 | return [ |
||
60 | 'w' => $this->getWidth(), |
||
61 | 'h' => $this->getHeight(), |
||
62 | 'd' => $this->getDepth(), |
||
63 | 'q' => $this->getQuantity(), |
||
64 | 'vr' => (int)$this->isVerticalRotationLock(), |
||
65 | 'id' => $this->getItemIdentifier(), |
||
66 | 'wg' => $this->getWeight(), |
||
67 | ]; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return mixed |
||
72 | */ |
||
73 | public function getWidth() |
||
74 | { |
||
75 | return $this->width; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param mixed $width |
||
80 | * @return Item |
||
81 | */ |
||
82 | public function setWidth($width) |
||
83 | { |
||
84 | $this->width = (float)$width; |
||
85 | |||
86 | return $this; |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function getHeight() |
||
93 | { |
||
94 | return $this->height; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param mixed $height |
||
99 | * @return Item |
||
100 | */ |
||
101 | public function setHeight($height) |
||
102 | { |
||
103 | $this->height = (float)$height; |
||
104 | |||
105 | return $this; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * @return mixed |
||
110 | */ |
||
111 | public function getDepth() |
||
112 | { |
||
113 | return $this->depth; |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * @param mixed $depth |
||
118 | * @return Item |
||
119 | */ |
||
120 | public function setDepth($depth) |
||
121 | { |
||
122 | $this->depth = (float)$depth; |
||
123 | |||
124 | return $this; |
||
125 | } |
||
126 | |||
127 | /** |
||
128 | * @return int |
||
129 | */ |
||
130 | public function getQuantity() |
||
131 | { |
||
132 | return $this->quantity; |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * @param int $quantity |
||
137 | * @return Item |
||
138 | */ |
||
139 | public function setQuantity($quantity) |
||
140 | { |
||
141 | $this->quantity = (int)$quantity; |
||
142 | |||
143 | return $this; |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * @return boolean |
||
148 | */ |
||
149 | public function isVerticalRotationLock() |
||
150 | { |
||
151 | return $this->verticalRotationLock; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * @param boolean $verticalRotationLock |
||
156 | * @return Item |
||
157 | */ |
||
158 | public function setVerticalRotationLock($verticalRotationLock) |
||
159 | { |
||
160 | $this->verticalRotationLock = (bool)$verticalRotationLock; |
||
161 | |||
162 | return $this; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * @return mixed |
||
167 | */ |
||
168 | public function getItemIdentifier() |
||
169 | { |
||
170 | return $this->itemIdentifier; |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * @param mixed $itemIdentifier |
||
175 | * @return Item |
||
176 | */ |
||
177 | public function setItemIdentifier($itemIdentifier) |
||
178 | { |
||
179 | $this->itemIdentifier = (string)$itemIdentifier; |
||
180 | |||
181 | return $this; |
||
182 | } |
||
183 | |||
184 | /** |
||
185 | * @return mixed |
||
186 | */ |
||
187 | public function getWeight() |
||
188 | { |
||
189 | return $this->weight; |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * @param mixed $weight |
||
194 | * @return Item |
||
195 | */ |
||
196 | public function setWeight($weight) |
||
197 | { |
||
198 | $this->weight = (float)$weight; |
||
199 | |||
200 | return $this; |
||
201 | } |
||
202 | |||
203 | /** |
||
204 | * @return bool |
||
205 | */ |
||
206 | View Code Duplication | final public function validate() |
|
0 ignored issues
–
show
|
|||
207 | { |
||
208 | return Utils::noEmptyItems([ |
||
209 | $this->getWidth(), |
||
210 | $this->getHeight(), |
||
211 | $this->getDepth(), |
||
212 | $this->getQuantity(), |
||
213 | $this->getItemIdentifier(), |
||
214 | $this->getWeight(), |
||
215 | ]); |
||
216 | } |
||
217 | |||
218 | /** |
||
219 | * @return mixed |
||
220 | */ |
||
221 | public function getProduct() |
||
222 | { |
||
223 | return $this->product; |
||
224 | } |
||
225 | |||
226 | /** |
||
227 | * @param mixed $product |
||
228 | * @return Item |
||
229 | */ |
||
230 | public function setProduct($product) |
||
231 | { |
||
232 | $this->product = $product; |
||
233 | |||
234 | return $this; |
||
235 | } |
||
236 | |||
237 | } |
||
238 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.