These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of EC-CUBE |
||
5 | * |
||
6 | * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
||
7 | * |
||
8 | * http://www.ec-cube.co.jp/ |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Eccube\Entity; |
||
15 | |||
16 | use Doctrine\Common\Collections\ArrayCollection; |
||
17 | use Doctrine\ORM\Mapping as ORM; |
||
18 | use Eccube\Service\PurchaseFlow\InvalidItemException; |
||
19 | use Eccube\Service\PurchaseFlow\ItemCollection; |
||
20 | |||
21 | 1 | if (!class_exists('\Eccube\Entity\Cart')) { |
|
22 | /** |
||
23 | * Cart |
||
24 | * |
||
25 | * @ORM\Table(name="dtb_cart", indexes={ |
||
26 | * @ORM\Index(name="dtb_cart_update_date_idx", columns={"update_date"}) |
||
27 | * }, |
||
28 | * uniqueConstraints={ |
||
29 | * @ORM\UniqueConstraint(name="dtb_cart_pre_order_id_idx", columns={"pre_order_id"}) |
||
30 | * })) |
||
31 | * @ORM\InheritanceType("SINGLE_TABLE") |
||
32 | * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255) |
||
33 | * @ORM\HasLifecycleCallbacks() |
||
34 | * @ORM\Entity(repositoryClass="Eccube\Repository\CartRepository") |
||
35 | */ |
||
36 | class Cart extends AbstractEntity implements PurchaseInterface, ItemHolderInterface |
||
37 | { |
||
38 | use PointTrait; |
||
39 | |||
40 | /** |
||
41 | * @var integer |
||
42 | * |
||
43 | * @ORM\Column(name="id", type="integer", options={"unsigned":true}) |
||
44 | * @ORM\Id |
||
45 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
46 | */ |
||
47 | private $id; |
||
48 | |||
49 | /** |
||
50 | * @var string |
||
51 | * |
||
52 | * @ORM\Column(name="cart_key", type="string", nullable=true) |
||
53 | */ |
||
54 | private $cart_key; |
||
55 | |||
56 | /** |
||
57 | * @var \Eccube\Entity\Customer |
||
58 | * |
||
59 | * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer") |
||
60 | * @ORM\JoinColumns({ |
||
61 | * @ORM\JoinColumn(name="customer_id", referencedColumnName="id") |
||
62 | * }) |
||
63 | */ |
||
64 | private $Customer; |
||
65 | |||
66 | /** |
||
67 | * @var bool |
||
68 | */ |
||
69 | private $lock = false; |
||
70 | |||
71 | /** |
||
72 | * @var \Doctrine\Common\Collections\Collection|CartItem[] |
||
73 | * |
||
74 | * @ORM\OneToMany(targetEntity="Eccube\Entity\CartItem", mappedBy="Cart", cascade={"persist"}) |
||
75 | */ |
||
76 | private $CartItems; |
||
77 | |||
78 | /** |
||
79 | * @var string|null |
||
80 | * |
||
81 | * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true) |
||
82 | */ |
||
83 | private $pre_order_id = null; |
||
84 | |||
85 | /** |
||
86 | * @var string |
||
87 | * |
||
88 | * @ORM\Column(name="total_price", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0}) |
||
89 | */ |
||
90 | private $total_price; |
||
91 | |||
92 | /** |
||
93 | * @var string |
||
94 | * |
||
95 | * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0}) |
||
96 | */ |
||
97 | private $delivery_fee_total; |
||
98 | |||
99 | /** |
||
100 | * @var int|null |
||
101 | * |
||
102 | * @ORM\Column(name="sort_no", type="smallint", nullable=true, options={"unsigned":true}) |
||
103 | */ |
||
104 | private $sort_no; |
||
105 | |||
106 | /** |
||
107 | * @var \DateTime |
||
108 | * |
||
109 | * @ORM\Column(name="create_date", type="datetimetz") |
||
110 | */ |
||
111 | private $create_date; |
||
112 | |||
113 | /** |
||
114 | * @var \DateTime |
||
115 | * |
||
116 | * @ORM\Column(name="update_date", type="datetimetz") |
||
117 | */ |
||
118 | private $update_date; |
||
119 | 100 | ||
120 | /** |
||
121 | 100 | * @var InvalidItemException[] |
|
122 | */ |
||
123 | private $errors = []; |
||
124 | |||
125 | public function __wakeup() |
||
126 | { |
||
127 | 2 | $this->errors = []; |
|
128 | } |
||
129 | 2 | ||
130 | public function __construct() |
||
131 | { |
||
132 | $this->CartItems = new ArrayCollection(); |
||
133 | } |
||
134 | |||
135 | 78 | /** |
|
136 | * @return int |
||
137 | 78 | */ |
|
138 | public function getId() |
||
139 | { |
||
140 | return $this->id; |
||
141 | } |
||
142 | |||
143 | 86 | /** |
|
144 | * @return string |
||
145 | 86 | */ |
|
146 | public function getCartKey() |
||
147 | { |
||
148 | return $this->cart_key; |
||
149 | } |
||
150 | |||
151 | /** |
||
152 | * @param string $cartKey |
||
153 | */ |
||
154 | public function setCartKey(string $cartKey) |
||
155 | { |
||
156 | $this->cart_key = $cartKey; |
||
157 | } |
||
158 | |||
159 | /** |
||
160 | * @return bool |
||
161 | * |
||
162 | * @deprecated 使用しないので削除予定 |
||
163 | */ |
||
164 | public function getLock() |
||
165 | { |
||
166 | return $this->lock; |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * @param bool $lock |
||
171 | * |
||
172 | * @return \Eccube\Entity\Cart |
||
173 | * |
||
174 | * @deprecated 使用しないので削除予定 |
||
175 | 53 | */ |
|
176 | public function setLock($lock) |
||
177 | 53 | { |
|
178 | $this->lock = $lock; |
||
179 | |||
180 | return $this; |
||
181 | } |
||
182 | |||
183 | /** |
||
184 | * @return string|null |
||
185 | 54 | */ |
|
186 | public function getPreOrderId() |
||
187 | 54 | { |
|
188 | return $this->pre_order_id; |
||
189 | 54 | } |
|
190 | |||
191 | /** |
||
192 | * @param integer $pre_order_id |
||
193 | * |
||
194 | * @return \Eccube\Entity\Cart |
||
195 | */ |
||
196 | public function setPreOrderId($pre_order_id) |
||
197 | 89 | { |
|
198 | $this->pre_order_id = $pre_order_id; |
||
0 ignored issues
–
show
|
|||
199 | 89 | ||
200 | return $this; |
||
201 | 89 | } |
|
202 | |||
203 | /** |
||
204 | * @param CartItem $CartItem |
||
205 | * |
||
206 | * @return \Eccube\Entity\Cart |
||
207 | */ |
||
208 | public function addCartItem(CartItem $CartItem) |
||
209 | { |
||
210 | $this->CartItems[] = $CartItem; |
||
211 | |||
212 | return $this; |
||
213 | } |
||
214 | |||
215 | /** |
||
216 | * @return \Eccube\Entity\Cart |
||
217 | 95 | */ |
|
218 | public function clearCartItems() |
||
219 | 95 | { |
|
220 | $this->CartItems->clear(); |
||
221 | |||
222 | return $this; |
||
223 | } |
||
224 | |||
225 | 92 | /** |
|
226 | * @return ArrayCollection|CartItem[] |
||
227 | 92 | */ |
|
228 | public function getCartItems() |
||
229 | { |
||
230 | return $this->CartItems; |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Alias of getCartItems() |
||
235 | */ |
||
236 | public function getItems() |
||
237 | { |
||
238 | return (new ItemCollection($this->getCartItems()))->sort(); |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * @param CartItem[] $CartItems |
||
243 | * |
||
244 | * @return \Eccube\Entity\Cart |
||
245 | */ |
||
246 | public function setCartItems($CartItems) |
||
247 | { |
||
248 | $this->CartItems = $CartItems; |
||
249 | 87 | ||
250 | return $this; |
||
251 | 87 | } |
|
252 | |||
253 | 87 | /** |
|
254 | * Set total. |
||
255 | * |
||
256 | * @param integer $total_price |
||
257 | * |
||
258 | * @return Cart |
||
259 | 80 | */ |
|
260 | public function setTotalPrice($total_price) |
||
261 | 80 | { |
|
262 | $this->total_price = $total_price; |
||
263 | |||
264 | return $this; |
||
265 | } |
||
266 | |||
267 | 85 | /** |
|
268 | * @return string |
||
269 | 85 | */ |
|
270 | public function getTotalPrice() |
||
271 | { |
||
272 | return $this->total_price; |
||
273 | } |
||
274 | |||
275 | 80 | /** |
|
276 | * Alias of setTotalPrice. |
||
277 | 80 | */ |
|
278 | public function setTotal($total) |
||
279 | { |
||
280 | return $this->setTotalPrice($total); |
||
281 | } |
||
282 | |||
283 | 71 | /** |
|
284 | * Alias of getTotalPrice |
||
285 | 71 | */ |
|
286 | 71 | public function getTotal() |
|
287 | 71 | { |
|
288 | return $this->getTotalPrice(); |
||
289 | } |
||
290 | 71 | ||
291 | /** |
||
292 | * @return integer |
||
293 | */ |
||
294 | public function getTotalQuantity() |
||
295 | { |
||
296 | 3 | $totalQuantity = 0; |
|
297 | foreach ($this->CartItems as $CartItem) { |
||
298 | 3 | $totalQuantity += $CartItem->getQuantity(); |
|
299 | } |
||
300 | |||
301 | return $totalQuantity; |
||
302 | } |
||
303 | |||
304 | /** |
||
305 | * @param ItemInterface $item |
||
306 | 35 | */ |
|
307 | public function addItem(ItemInterface $item) |
||
308 | 35 | { |
|
309 | $this->CartItems->add($item); |
||
310 | } |
||
311 | |||
312 | /** |
||
313 | * @param ItemInterface $item |
||
314 | 85 | */ |
|
315 | public function removeItem(ItemInterface $item) |
||
316 | 85 | { |
|
317 | $this->CartItems->removeElement($item); |
||
318 | 85 | } |
|
319 | |||
320 | /** |
||
321 | * 個数の合計を返します。 |
||
322 | * |
||
323 | * @return integer |
||
324 | */ |
||
325 | public function getQuantity() |
||
326 | { |
||
327 | return $this->getTotalQuantity(); |
||
328 | } |
||
329 | |||
330 | /** |
||
331 | * {@inheritdoc} |
||
332 | */ |
||
333 | public function setDeliveryFeeTotal($total) |
||
334 | { |
||
335 | $this->delivery_fee_total = $total; |
||
336 | |||
337 | return $this; |
||
338 | } |
||
339 | |||
340 | 78 | /** |
|
341 | * {@inheritdoc} |
||
342 | 78 | */ |
|
343 | public function getDeliveryFeeTotal() |
||
344 | { |
||
345 | return $this->delivery_fee_total; |
||
346 | } |
||
347 | |||
348 | /** |
||
349 | * @return Customer |
||
350 | */ |
||
351 | public function getCustomer(): Customer |
||
352 | 80 | { |
|
353 | return $this->Customer; |
||
354 | 80 | } |
|
355 | |||
356 | 80 | /** |
|
357 | * @param Customer $Customer |
||
358 | */ |
||
359 | public function setCustomer(Customer $Customer = null) |
||
360 | { |
||
361 | $this->Customer = $Customer; |
||
362 | } |
||
363 | |||
364 | /** |
||
365 | * Set sortNo. |
||
366 | * |
||
367 | * @param int|null $sortNo |
||
368 | * |
||
369 | * @return Cart |
||
370 | */ |
||
371 | public function setSortNo($sortNo = null) |
||
372 | { |
||
373 | $this->sort_no = $sortNo; |
||
374 | |||
375 | return $this; |
||
376 | 80 | } |
|
377 | |||
378 | 80 | /** |
|
379 | * Get sortNo. |
||
380 | 80 | * |
|
381 | * @return int|null |
||
382 | */ |
||
383 | public function getSortNo() |
||
384 | { |
||
385 | return $this->sort_no; |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * Set createDate. |
||
390 | * |
||
391 | * @param \DateTime $createDate |
||
392 | * |
||
393 | * @return Cart |
||
394 | */ |
||
395 | public function setCreateDate($createDate) |
||
396 | { |
||
397 | $this->create_date = $createDate; |
||
398 | |||
399 | return $this; |
||
400 | } |
||
401 | |||
402 | /** |
||
403 | * Get createDate. |
||
404 | * |
||
405 | * @return \DateTime |
||
406 | */ |
||
407 | public function getCreateDate() |
||
408 | { |
||
409 | return $this->create_date; |
||
410 | } |
||
411 | |||
412 | /** |
||
413 | * Set updateDate. |
||
414 | * |
||
415 | * @param \DateTime $updateDate |
||
416 | * |
||
417 | * @return Cart |
||
418 | */ |
||
419 | public function setUpdateDate($updateDate) |
||
420 | { |
||
421 | $this->update_date = $updateDate; |
||
422 | |||
423 | return $this; |
||
424 | } |
||
425 | |||
426 | /** |
||
427 | * Get updateDate. |
||
428 | * |
||
429 | * @return \DateTime |
||
430 | */ |
||
431 | public function getUpdateDate() |
||
432 | { |
||
433 | return $this->update_date; |
||
434 | } |
||
435 | |||
436 | /** |
||
437 | * {@inheritdoc} |
||
438 | */ |
||
439 | public function setDiscount($total) |
||
440 | { |
||
441 | // TODO quiet |
||
442 | } |
||
443 | |||
444 | /** |
||
445 | * {@inheritdoc} |
||
446 | */ |
||
447 | public function setCharge($total) |
||
448 | { |
||
449 | // TODO quiet |
||
450 | } |
||
451 | |||
452 | /** |
||
453 | * {@inheritdoc} |
||
454 | * |
||
455 | * @deprecated |
||
456 | */ |
||
457 | public function setTax($total) |
||
458 | { |
||
459 | // TODO quiet |
||
460 | } |
||
461 | } |
||
462 | } |
||
463 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..