Failed Conditions
Pull Request — experimental/sf (#31)
by Kentaro
06:59
created

Order   F

Complexity

Total Complexity 113

Size/Duplication

Total Lines 1604
Duplicated Lines 0 %

Coupling/Cohesion

Components 6
Dependencies 11

Importance

Changes 0
Metric Value
dl 0
loc 1604
rs 0.8
c 0
b 0
f 0
wmc 113
lcom 6
cbo 11

101 Methods

Rating   Name   Duplication   Size   Complexity  
A isMultiple() 0 17 5
A findShipping() 0 10 3
A getSaleTypes() 0 13 3
A getMergedProductOrderItems() 0 30 3
A getTotalPrice() 0 7 1
A __construct() 0 16 1
A __clone() 0 8 2
A getId() 0 4 1
A setPreOrderId() 0 6 1
A getPreOrderId() 0 4 1
A setOrderNo() 0 6 1
A getOrderNo() 0 4 1
A setMessage() 0 6 1
A getMessage() 0 4 1
A setName01() 0 6 1
A getName01() 0 4 1
A setName02() 0 6 1
A getName02() 0 4 1
A setKana01() 0 6 1
A getKana01() 0 4 1
A setKana02() 0 6 1
A getKana02() 0 4 1
A setCompanyName() 0 6 1
A getCompanyName() 0 4 1
A setEmail() 0 6 1
A getEmail() 0 4 1
A setPhoneNumber() 0 6 1
A getPhoneNumber() 0 4 1
A setPostalCode() 0 6 1
A getPostalCode() 0 4 1
A setAddr01() 0 6 1
A getAddr01() 0 4 1
A setAddr02() 0 6 1
A getAddr02() 0 4 1
A setBirth() 0 6 1
A getBirth() 0 4 1
A setSubtotal() 0 6 1
A getSubtotal() 0 4 1
A setDiscount() 0 6 1
A getDiscount() 0 4 1
A setDeliveryFeeTotal() 0 6 1
A getDeliveryFeeTotal() 0 4 1
A setCharge() 0 6 1
A getCharge() 0 4 1
A setTax() 0 6 1
A getTax() 0 4 1
A setTotal() 0 6 1
A getTotal() 0 4 1
A setPaymentTotal() 0 6 1
A getPaymentTotal() 0 4 1
A setPaymentMethod() 0 6 1
A getPaymentMethod() 0 4 1
A setNote() 0 6 1
A getNote() 0 4 1
A setCreateDate() 0 6 1
A getCreateDate() 0 4 1
A setUpdateDate() 0 6 1
A getUpdateDate() 0 4 1
A setOrderDate() 0 6 1
A getOrderDate() 0 4 1
A setPaymentDate() 0 6 1
A getPaymentDate() 0 4 1
A getCurrencyCode() 0 4 1
A setCurrencyCode() 0 6 1
A getCompleteMessage() 0 4 1
A setCompleteMessage() 0 6 1
A appendCompleteMessage() 0 6 1
A getCompleteMailMessage() 0 4 1
A setCompleteMailMessage() 0 6 1
A appendCompleteMailMessage() 0 6 1
A getProductOrderItems() 0 6 1
A addOrderItem() 0 6 1
A removeOrderItem() 0 4 1
A getOrderItems() 0 4 1
A getItems() 0 4 1
A addShipping() 0 6 1
A removeShipping() 0 4 1
A getShippings() 0 7 1
A addMailHistory() 0 6 1
A removeMailHistory() 0 4 1
A getMailHistories() 0 4 1
A setCustomer() 0 6 1
A getCustomer() 0 4 1
A setCountry() 0 6 1
A getCountry() 0 4 1
A setPref() 0 6 1
A getPref() 0 4 1
A setSex() 0 6 1
A getSex() 0 4 1
A setJob() 0 6 1
A getJob() 0 4 1
A setPayment() 0 6 1
A getPayment() 0 4 1
A setDeviceType() 0 6 1
A getDeviceType() 0 4 1
A setCustomerOrderStatus() 0 6 1
A getCustomerOrderStatus() 0 4 1
A setOrderStatus() 0 6 1
A getOrderStatus() 0 4 1
A addItem() 0 4 1
A getQuantity() 0 9 2

How to fix   Complexity   

Complex Class

Complex classes like Order often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Order, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.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\Common\Collections\Criteria;
18
use Doctrine\ORM\Mapping as ORM;
19
use Eccube\Service\Calculator\OrderItemCollection;
20
use Eccube\Service\PurchaseFlow\ItemCollection;
21
22
if (!class_exists('\Eccube\Entity\Order')) {
23
    /**
24
     * Order
25
     *
26
     * @ORM\Table(name="dtb_order", indexes={
27
     *     @ORM\Index(name="dtb_order_pre_order_id_idx", columns={"pre_order_id"}),
28
     *     @ORM\Index(name="dtb_order_email_idx", columns={"email"}),
29
     *     @ORM\Index(name="dtb_order_order_date_idx", columns={"order_date"}),
30
     *     @ORM\Index(name="dtb_order_payment_date_idx", columns={"payment_date"}),
31
     *     @ORM\Index(name="dtb_order_update_date_idx", columns={"update_date"}),
32
     *     @ORM\Index(name="dtb_order_order_no_idx", columns={"order_no"})
33
     *  })
34
     * @ORM\InheritanceType("SINGLE_TABLE")
35
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
36
     * @ORM\HasLifecycleCallbacks()
37
     * @ORM\Entity(repositoryClass="Eccube\Repository\OrderRepository")
38
     */
39
    class Order extends \Eccube\Entity\AbstractEntity implements PurchaseInterface, ItemHolderInterface
40
    {
41
        use NameTrait, PointTrait;
42
43
        /**
44
         * 複数配送かどうかの判定を行う.
45
         *
46
         * @return boolean
47
         */
48
        public function isMultiple()
49
        {
50
            $Shippings = [];
51
            // クエリビルダ使用時に絞り込まれる場合があるため,
52
            // getShippingsではなくOrderItem経由でShippingを取得する.
53
            foreach ($this->getOrderItems() as $OrderItem) {
54
                if ($Shipping = $OrderItem->getShipping()) {
55
                    $id = $Shipping->getId();
56
                    if (isset($Shippings[$id])) {
57
                        continue;
58
                    }
59
                    $Shippings[$id] = $Shipping;
60
                }
61
            }
62
63
            return count($Shippings) > 1 ? true : false;
64
        }
65
66
        /**
67
         * 対象となるお届け先情報を取得
68
         *
69
         * @param integer $shippingId
70
         *
71
         * @return \Eccube\Entity\Shipping|null
72
         */
73
        public function findShipping($shippingId)
74
        {
75
            foreach ($this->getShippings() as $Shipping) {
76
                if ($Shipping->getId() == $shippingId) {
77
                    return $Shipping;
78
                }
79
            }
80
81
            return null;
82
        }
83
84
        /**
85
         * この注文の保持する販売種別を取得します.
86
         *
87
         * @return \Eccube\Entity\Master\SaleType[] 一意な販売種別の配列
88
         */
89
        public function getSaleTypes()
90
        {
91
            $saleTypes = [];
92
            foreach ($this->getOrderItems() as $OrderItem) {
93
                /* @var $ProductClass \Eccube\Entity\ProductClass */
94
                $ProductClass = $OrderItem->getProductClass();
95
                if ($ProductClass) {
96
                    $saleTypes[] = $ProductClass->getSaleType();
97
                }
98
            }
99
100
            return array_unique($saleTypes);
101
        }
102
103
        /**
104
         * 同じ規格の商品の個数をまとめた受注明細を取得
105
         *
106
         * @return OrderItem[]
107
         */
108
        public function getMergedProductOrderItems()
109
        {
110
            $ProductOrderItems = $this->getProductOrderItems();
111
            $orderItemArray = [];
112
            /** @var OrderItem $ProductOrderItem */
113
            foreach ($ProductOrderItems as $ProductOrderItem) {
114
                $productClassId = $ProductOrderItem->getProductClass()->getId();
115
                if (array_key_exists($productClassId, $orderItemArray)) {
116
                    // 同じ規格の商品がある場合は個数をまとめる
117
                    /** @var ItemInterface $OrderItem */
118
                    $OrderItem = $orderItemArray[$productClassId];
119
                    $quantity = $OrderItem->getQuantity() + $ProductOrderItem->getQuantity();
120
                    $OrderItem->setQuantity($quantity);
121
                } else {
122
                    // 新規規格の商品は新しく追加する
123
                    $OrderItem = new OrderItem();
124
                    $OrderItem
125
                    ->setProduct($ProductOrderItem->getProduct())
126
                    ->setProductName($ProductOrderItem->getProductName())
127
                    ->setClassCategoryName1($ProductOrderItem->getClassCategoryName1())
128
                    ->setClassCategoryName2($ProductOrderItem->getClassCategoryName2())
129
                    ->setPrice($ProductOrderItem->getPrice())
130
                    ->setTax($ProductOrderItem->getTax())
131
                    ->setQuantity($ProductOrderItem->getQuantity());
132
                    $orderItemArray[$productClassId] = $OrderItem;
133
                }
134
            }
135
136
            return array_values($orderItemArray);
137
        }
138
139
        /**
140
         * 合計金額を計算
141
         *
142
         * @return string
143
         *
144
         * @deprecated
145
         */
146
        public function getTotalPrice()
147
        {
148
            @trigger_error('The '.__METHOD__.' method is deprecated.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
149
150
            return $this->getSubtotal() + $this->getCharge() + $this->getDeliveryFeeTotal() - $this->getDiscount();
151
//        return $this->getSubtotal() + $this->getCharge() - $this->getDiscount();
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
152
        }
153
154
        /**
155
         * @var integer
156
         *
157
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
158
         * @ORM\Id
159
         * @ORM\GeneratedValue(strategy="IDENTITY")
160
         */
161
        private $id;
162
163
        /**
164
         * @var string|null
165
         *
166
         * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true)
167
         */
168
        private $pre_order_id;
169
170
        /**
171
         * @var string|null
172
         *
173
         * @ORM\Column(name="order_no", type="string", length=255, nullable=true)
174
         */
175
        private $order_no;
176
177
        /**
178
         * @var string|null
179
         *
180
         * @ORM\Column(name="message", type="string", length=4000, nullable=true)
181
         */
182
        private $message;
183
184
        /**
185
         * @var string|null
186
         *
187
         * @ORM\Column(name="name01", type="string", length=255, nullable=true)
188
         */
189
        private $name01;
190
191
        /**
192
         * @var string|null
193
         *
194
         * @ORM\Column(name="name02", type="string", length=255, nullable=true)
195
         */
196
        private $name02;
197
198
        /**
199
         * @var string|null
200
         *
201
         * @ORM\Column(name="kana01", type="string", length=255, nullable=true)
202
         */
203
        private $kana01;
204
205
        /**
206
         * @var string|null
207
         *
208
         * @ORM\Column(name="kana02", type="string", length=255, nullable=true)
209
         */
210
        private $kana02;
211
212
        /**
213
         * @var string|null
214
         *
215
         * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
216
         */
217
        private $company_name;
218
219
        /**
220
         * @var string|null
221
         *
222
         * @ORM\Column(name="email", type="string", length=255, nullable=true)
223
         */
224
        private $email;
225
226
        /**
227
         * @var string|null
228
         *
229
         * @ORM\Column(name="phone_number", type="string", length=14, nullable=true)
230
         */
231
        private $phone_number;
232
233
        /**
234
         * @var string|null
235
         *
236
         * @ORM\Column(name="postal_code", type="string", length=8, nullable=true)
237
         */
238
        private $postal_code;
239
240
        /**
241
         * @var string|null
242
         *
243
         * @ORM\Column(name="addr01", type="string", length=255, nullable=true)
244
         */
245
        private $addr01;
246
247
        /**
248
         * @var string|null
249
         *
250
         * @ORM\Column(name="addr02", type="string", length=255, nullable=true)
251
         */
252
        private $addr02;
253
254
        /**
255
         * @var \DateTime|null
256
         *
257
         * @ORM\Column(name="birth", type="datetimetz", nullable=true)
258
         */
259
        private $birth;
260
261
        /**
262
         * @var string
263
         *
264
         * @ORM\Column(name="subtotal", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
265
         */
266
        private $subtotal = 0;
267
268
        /**
269
         * @var string
270
         *
271
         * @ORM\Column(name="discount", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
272
         */
273
        private $discount = 0;
274
275
        /**
276
         * @var string
277
         *
278
         * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
279
         */
280
        private $delivery_fee_total = 0;
281
282
        /**
283
         * @var string
284
         *
285
         * @ORM\Column(name="charge", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
286
         */
287
        private $charge = 0;
288
289
        /**
290
         * @var string
291
         *
292
         * @ORM\Column(name="tax", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
293
         */
294
        private $tax = 0;
295
296
        /**
297
         * @var string
298
         *
299
         * @ORM\Column(name="total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
300
         */
301
        private $total = 0;
302
303
        /**
304
         * @var string
305
         *
306
         * @ORM\Column(name="payment_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
307
         */
308
        private $payment_total = 0;
309
310
        /**
311
         * @var string|null
312
         *
313
         * @ORM\Column(name="payment_method", type="string", length=255, nullable=true)
314
         */
315
        private $payment_method;
316
317
        /**
318
         * @var string|null
319
         *
320
         * @ORM\Column(name="note", type="string", length=4000, nullable=true)
321
         */
322
        private $note;
323
324
        /**
325
         * @var \DateTime
326
         *
327
         * @ORM\Column(name="create_date", type="datetimetz")
328
         */
329
        private $create_date;
330
331
        /**
332
         * @var \DateTime
333
         *
334
         * @ORM\Column(name="update_date", type="datetimetz")
335
         */
336
        private $update_date;
337
338
        /**
339
         * @var \DateTime|null
340
         *
341
         * @ORM\Column(name="order_date", type="datetimetz", nullable=true)
342
         */
343
        private $order_date;
344
345
        /**
346
         * @var \DateTime|null
347
         *
348
         * @ORM\Column(name="payment_date", type="datetimetz", nullable=true)
349
         */
350
        private $payment_date;
351
352
        /**
353
         * @var string|null
354
         *
355
         * @ORM\Column(name="currency_code", type="string", nullable=true)
356
         */
357
        private $currency_code;
358
359
        /**
360
         * 注文完了画面に表示するメッセージ
361
         *
362
         * プラグインから注文完了時にメッセージを表示したい場合, このフィールドにセットすることで, 注文完了画面で表示されます。
363
         * 複数のプラグインから利用されるため, appendCompleteMesssage()で追加してください.
364
         * 表示する際にHTMLは利用可能です。
365
         *
366
         * @var string|null
367
         *
368
         * @ORM\Column(name="complete_message", type="text", nullable=true)
369
         */
370
        private $complete_message;
371
372
        /**
373
         * 注文完了メールに表示するメッセージ
374
         *
375
         * プラグインから注文完了メールにメッセージを表示したい場合, このフィールドにセットすることで, 注文完了メールで表示されます。
376
         * 複数のプラグインから利用されるため, appendCompleteMailMesssage()で追加してください.
377
         *
378
         * @var string|null
379
         *
380
         * @ORM\Column(name="complete_mail_message", type="text", nullable=true)
381
         */
382
        private $complete_mail_message;
383
384
        /**
385
         * @var \Doctrine\Common\Collections\Collection|OrderItem[]
386
         *
387
         * @ORM\OneToMany(targetEntity="Eccube\Entity\OrderItem", mappedBy="Order", cascade={"persist","remove"})
388
         */
389
        private $OrderItems;
390
391
        /**
392
         * @var \Doctrine\Common\Collections\Collection|Shipping[]
393
         *
394
         * @ORM\OneToMany(targetEntity="Eccube\Entity\Shipping", mappedBy="Order", cascade={"persist","remove"})
395
         */
396
        private $Shippings;
397
398
        /**
399
         * @var \Doctrine\Common\Collections\Collection
400
         *
401
         * @ORM\OneToMany(targetEntity="Eccube\Entity\MailHistory", mappedBy="Order", cascade={"remove"})
402
         * @ORM\OrderBy({
403
         *     "send_date"="DESC"
404
         * })
405
         */
406
        private $MailHistories;
407
408
        /**
409
         * @var \Eccube\Entity\Customer
410
         *
411
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer", inversedBy="Orders")
412
         * @ORM\JoinColumns({
413
         *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
414
         * })
415
         */
416
        private $Customer;
417
418
        /**
419
         * @var \Eccube\Entity\Master\Country
420
         *
421
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Country")
422
         * @ORM\JoinColumns({
423
         *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
424
         * })
425
         */
426
        private $Country;
427
428
        /**
429
         * @var \Eccube\Entity\Master\Pref
430
         *
431
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Pref")
432
         * @ORM\JoinColumns({
433
         *   @ORM\JoinColumn(name="pref_id", referencedColumnName="id")
434
         * })
435
         */
436
        private $Pref;
437
438
        /**
439
         * @var \Eccube\Entity\Master\Sex
440
         *
441
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Sex")
442
         * @ORM\JoinColumns({
443
         *   @ORM\JoinColumn(name="sex_id", referencedColumnName="id")
444
         * })
445
         */
446
        private $Sex;
447
448
        /**
449
         * @var \Eccube\Entity\Master\Job
450
         *
451
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Job")
452
         * @ORM\JoinColumns({
453
         *   @ORM\JoinColumn(name="job_id", referencedColumnName="id")
454
         * })
455
         */
456
        private $Job;
457
458
        /**
459
         * @var \Eccube\Entity\Payment
460
         *
461
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Payment")
462
         * @ORM\JoinColumns({
463
         *   @ORM\JoinColumn(name="payment_id", referencedColumnName="id")
464
         * })
465
         */
466
        private $Payment;
467
468
        /**
469
         * @var \Eccube\Entity\Master\DeviceType
470
         *
471
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\DeviceType")
472
         * @ORM\JoinColumns({
473
         *   @ORM\JoinColumn(name="device_type_id", referencedColumnName="id")
474
         * })
475
         */
476
        private $DeviceType;
477
478
        /**
479
         * @var \Eccube\Entity\Master\CustomerOrderStatus
480
         *
481
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\CustomerOrderStatus")
482
         * @ORM\JoinColumns({
483
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
484
         * })
485
         */
486
        private $CustomerOrderStatus;
487
488
        /**
489
         * @var \Eccube\Entity\Master\OrderStatus
490
         *
491
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatus")
492
         * @ORM\JoinColumns({
493
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
494
         * })
495
         */
496
        private $OrderStatus;
497
498
        /**
499
         * Constructor
500
         */
501
        public function __construct(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
502
        {
503
            $this->setDiscount(0)
504
            ->setSubtotal(0)
505
            ->setTotal(0)
506
            ->setPaymentTotal(0)
507
            ->setCharge(0)
508
            ->setTax(0)
509
            ->setDeliveryFeeTotal(0)
510
            ->setOrderStatus($orderStatus)
511
        ;
512
513
            $this->OrderItems = new \Doctrine\Common\Collections\ArrayCollection();
514
            $this->Shippings = new \Doctrine\Common\Collections\ArrayCollection();
515
            $this->MailHistories = new \Doctrine\Common\Collections\ArrayCollection();
516
        }
517
518
        /**
519
         * Clone
520
         */
521
        public function __clone()
522
        {
523
            $OrderItems = new ArrayCollection();
524
            foreach ($this->OrderItems as $OrderItem) {
525
                $OrderItems->add(clone $OrderItem);
526
            }
527
            $this->OrderItems = $OrderItems;
528
        }
529
530
        /**
531
         * Get id.
532
         *
533
         * @return int
534
         */
535
        public function getId()
536
        {
537
            return $this->id;
538
        }
539
540
        /**
541
         * Set preOrderId.
542
         *
543
         * @param string|null $preOrderId
544
         *
545
         * @return Order
546
         */
547
        public function setPreOrderId($preOrderId = null)
548
        {
549
            $this->pre_order_id = $preOrderId;
550
551
            return $this;
552
        }
553
554
        /**
555
         * Get preOrderId.
556
         *
557
         * @return string|null
558
         */
559
        public function getPreOrderId()
560
        {
561
            return $this->pre_order_id;
562
        }
563
564
        /**
565
         * Set orderNo
566
         *
567
         * @param string|null $orderNo
568
         *
569
         * @return Order
570
         */
571
        public function setOrderNo($orderNo = null)
572
        {
573
            $this->order_no = $orderNo;
574
575
            return $this;
576
        }
577
578
        /**
579
         * Get orderNo
580
         *
581
         * @return string|null
582
         */
583
        public function getOrderNo()
584
        {
585
            return $this->order_no;
586
        }
587
588
        /**
589
         * Set message.
590
         *
591
         * @param string|null $message
592
         *
593
         * @return Order
594
         */
595
        public function setMessage($message = null)
596
        {
597
            $this->message = $message;
598
599
            return $this;
600
        }
601
602
        /**
603
         * Get message.
604
         *
605
         * @return string|null
606
         */
607
        public function getMessage()
608
        {
609
            return $this->message;
610
        }
611
612
        /**
613
         * Set name01.
614
         *
615
         * @param string|null $name01
616
         *
617
         * @return Order
618
         */
619
        public function setName01($name01 = null)
620
        {
621
            $this->name01 = $name01;
622
623
            return $this;
624
        }
625
626
        /**
627
         * Get name01.
628
         *
629
         * @return string|null
630
         */
631
        public function getName01()
632
        {
633
            return $this->name01;
634
        }
635
636
        /**
637
         * Set name02.
638
         *
639
         * @param string|null $name02
640
         *
641
         * @return Order
642
         */
643
        public function setName02($name02 = null)
644
        {
645
            $this->name02 = $name02;
646
647
            return $this;
648
        }
649
650
        /**
651
         * Get name02.
652
         *
653
         * @return string|null
654
         */
655
        public function getName02()
656
        {
657
            return $this->name02;
658
        }
659
660
        /**
661
         * Set kana01.
662
         *
663
         * @param string|null $kana01
664
         *
665
         * @return Order
666
         */
667
        public function setKana01($kana01 = null)
668
        {
669
            $this->kana01 = $kana01;
670
671
            return $this;
672
        }
673
674
        /**
675
         * Get kana01.
676
         *
677
         * @return string|null
678
         */
679
        public function getKana01()
680
        {
681
            return $this->kana01;
682
        }
683
684
        /**
685
         * Set kana02.
686
         *
687
         * @param string|null $kana02
688
         *
689
         * @return Order
690
         */
691
        public function setKana02($kana02 = null)
692
        {
693
            $this->kana02 = $kana02;
694
695
            return $this;
696
        }
697
698
        /**
699
         * Get kana02.
700
         *
701
         * @return string|null
702
         */
703
        public function getKana02()
704
        {
705
            return $this->kana02;
706
        }
707
708
        /**
709
         * Set companyName.
710
         *
711
         * @param string|null $companyName
712
         *
713
         * @return Order
714
         */
715
        public function setCompanyName($companyName = null)
716
        {
717
            $this->company_name = $companyName;
718
719
            return $this;
720
        }
721
722
        /**
723
         * Get companyName.
724
         *
725
         * @return string|null
726
         */
727
        public function getCompanyName()
728
        {
729
            return $this->company_name;
730
        }
731
732
        /**
733
         * Set email.
734
         *
735
         * @param string|null $email
736
         *
737
         * @return Order
738
         */
739
        public function setEmail($email = null)
740
        {
741
            $this->email = $email;
742
743
            return $this;
744
        }
745
746
        /**
747
         * Get email.
748
         *
749
         * @return string|null
750
         */
751
        public function getEmail()
752
        {
753
            return $this->email;
754
        }
755
756
        /**
757
         * Set phone_number.
758
         *
759
         * @param string|null $phone_number
760
         *
761
         * @return Order
762
         */
763
        public function setPhoneNumber($phone_number = null)
764
        {
765
            $this->phone_number = $phone_number;
766
767
            return $this;
768
        }
769
770
        /**
771
         * Get phone_number.
772
         *
773
         * @return string|null
774
         */
775
        public function getPhoneNumber()
776
        {
777
            return $this->phone_number;
778
        }
779
780
        /**
781
         * Set postal_code.
782
         *
783
         * @param string|null $postal_code
784
         *
785
         * @return Order
786
         */
787
        public function setPostalCode($postal_code = null)
788
        {
789
            $this->postal_code = $postal_code;
790
791
            return $this;
792
        }
793
794
        /**
795
         * Get postal_code.
796
         *
797
         * @return string|null
798
         */
799
        public function getPostalCode()
800
        {
801
            return $this->postal_code;
802
        }
803
804
        /**
805
         * Set addr01.
806
         *
807
         * @param string|null $addr01
808
         *
809
         * @return Order
810
         */
811
        public function setAddr01($addr01 = null)
812
        {
813
            $this->addr01 = $addr01;
814
815
            return $this;
816
        }
817
818
        /**
819
         * Get addr01.
820
         *
821
         * @return string|null
822
         */
823
        public function getAddr01()
824
        {
825
            return $this->addr01;
826
        }
827
828
        /**
829
         * Set addr02.
830
         *
831
         * @param string|null $addr02
832
         *
833
         * @return Order
834
         */
835
        public function setAddr02($addr02 = null)
836
        {
837
            $this->addr02 = $addr02;
838
839
            return $this;
840
        }
841
842
        /**
843
         * Get addr02.
844
         *
845
         * @return string|null
846
         */
847
        public function getAddr02()
848
        {
849
            return $this->addr02;
850
        }
851
852
        /**
853
         * Set birth.
854
         *
855
         * @param \DateTime|null $birth
856
         *
857
         * @return Order
858
         */
859
        public function setBirth($birth = null)
860
        {
861
            $this->birth = $birth;
862
863
            return $this;
864
        }
865
866
        /**
867
         * Get birth.
868
         *
869
         * @return \DateTime|null
870
         */
871
        public function getBirth()
872
        {
873
            return $this->birth;
874
        }
875
876
        /**
877
         * Set subtotal.
878
         *
879
         * @param string $subtotal
880
         *
881
         * @return Order
882
         */
883
        public function setSubtotal($subtotal)
884
        {
885
            $this->subtotal = $subtotal;
886
887
            return $this;
888
        }
889
890
        /**
891
         * Get subtotal.
892
         *
893
         * @return string
894
         */
895
        public function getSubtotal()
896
        {
897
            return $this->subtotal;
898
        }
899
900
        /**
901
         * Set discount.
902
         *
903
         * @param string $discount
904
         *
905
         * @return Order
906
         */
907
        public function setDiscount($discount)
908
        {
909
            $this->discount = $discount;
910
911
            return $this;
912
        }
913
914
        /**
915
         * Get discount.
916
         *
917
         * @return string
918
         */
919
        public function getDiscount()
920
        {
921
            return $this->discount;
922
        }
923
924
        /**
925
         * Set deliveryFeeTotal.
926
         *
927
         * @param string $deliveryFeeTotal
928
         *
929
         * @return Order
930
         */
931
        public function setDeliveryFeeTotal($deliveryFeeTotal)
932
        {
933
            $this->delivery_fee_total = $deliveryFeeTotal;
934
935
            return $this;
936
        }
937
938
        /**
939
         * Get deliveryFeeTotal.
940
         *
941
         * @return string
942
         */
943
        public function getDeliveryFeeTotal()
944
        {
945
            return $this->delivery_fee_total;
946
        }
947
948
        /**
949
         * Set charge.
950
         *
951
         * @param string $charge
952
         *
953
         * @return Order
954
         */
955
        public function setCharge($charge)
956
        {
957
            $this->charge = $charge;
958
959
            return $this;
960
        }
961
962
        /**
963
         * Get charge.
964
         *
965
         * @return string
966
         */
967
        public function getCharge()
968
        {
969
            return $this->charge;
970
        }
971
972
        /**
973
         * Set tax.
974
         *
975
         * @param string $tax
976
         *
977
         * @return Order
978
         */
979
        public function setTax($tax)
980
        {
981
            $this->tax = $tax;
982
983
            return $this;
984
        }
985
986
        /**
987
         * Get tax.
988
         *
989
         * @return string
990
         */
991
        public function getTax()
992
        {
993
            return $this->tax;
994
        }
995
996
        /**
997
         * Set total.
998
         *
999
         * @param string $total
1000
         *
1001
         * @return Order
1002
         */
1003
        public function setTotal($total)
1004
        {
1005
            $this->total = $total;
1006
1007
            return $this;
1008
        }
1009
1010
        /**
1011
         * Get total.
1012
         *
1013
         * @return string
1014
         */
1015
        public function getTotal()
1016
        {
1017
            return $this->total;
1018
        }
1019
1020
        /**
1021
         * Set paymentTotal.
1022
         *
1023
         * @param string $paymentTotal
1024
         *
1025
         * @return Order
1026
         */
1027
        public function setPaymentTotal($paymentTotal)
1028
        {
1029
            $this->payment_total = $paymentTotal;
1030
1031
            return $this;
1032
        }
1033
1034
        /**
1035
         * Get paymentTotal.
1036
         *
1037
         * @return string
1038
         */
1039
        public function getPaymentTotal()
1040
        {
1041
            return $this->payment_total;
1042
        }
1043
1044
        /**
1045
         * Set paymentMethod.
1046
         *
1047
         * @param string|null $paymentMethod
1048
         *
1049
         * @return Order
1050
         */
1051
        public function setPaymentMethod($paymentMethod = null)
1052
        {
1053
            $this->payment_method = $paymentMethod;
1054
1055
            return $this;
1056
        }
1057
1058
        /**
1059
         * Get paymentMethod.
1060
         *
1061
         * @return string|null
1062
         */
1063
        public function getPaymentMethod()
1064
        {
1065
            return $this->payment_method;
1066
        }
1067
1068
        /**
1069
         * Set note.
1070
         *
1071
         * @param string|null $note
1072
         *
1073
         * @return Order
1074
         */
1075
        public function setNote($note = null)
1076
        {
1077
            $this->note = $note;
1078
1079
            return $this;
1080
        }
1081
1082
        /**
1083
         * Get note.
1084
         *
1085
         * @return string|null
1086
         */
1087
        public function getNote()
1088
        {
1089
            return $this->note;
1090
        }
1091
1092
        /**
1093
         * Set createDate.
1094
         *
1095
         * @param \DateTime $createDate
1096
         *
1097
         * @return Order
1098
         */
1099
        public function setCreateDate($createDate)
1100
        {
1101
            $this->create_date = $createDate;
1102
1103
            return $this;
1104
        }
1105
1106
        /**
1107
         * Get createDate.
1108
         *
1109
         * @return \DateTime
1110
         */
1111
        public function getCreateDate()
1112
        {
1113
            return $this->create_date;
1114
        }
1115
1116
        /**
1117
         * Set updateDate.
1118
         *
1119
         * @param \DateTime $updateDate
1120
         *
1121
         * @return Order
1122
         */
1123
        public function setUpdateDate($updateDate)
1124
        {
1125
            $this->update_date = $updateDate;
1126
1127
            return $this;
1128
        }
1129
1130
        /**
1131
         * Get updateDate.
1132
         *
1133
         * @return \DateTime
1134
         */
1135
        public function getUpdateDate()
1136
        {
1137
            return $this->update_date;
1138
        }
1139
1140
        /**
1141
         * Set orderDate.
1142
         *
1143
         * @param \DateTime|null $orderDate
1144
         *
1145
         * @return Order
1146
         */
1147
        public function setOrderDate($orderDate = null)
1148
        {
1149
            $this->order_date = $orderDate;
1150
1151
            return $this;
1152
        }
1153
1154
        /**
1155
         * Get orderDate.
1156
         *
1157
         * @return \DateTime|null
1158
         */
1159
        public function getOrderDate()
1160
        {
1161
            return $this->order_date;
1162
        }
1163
1164
        /**
1165
         * Set paymentDate.
1166
         *
1167
         * @param \DateTime|null $paymentDate
1168
         *
1169
         * @return Order
1170
         */
1171
        public function setPaymentDate($paymentDate = null)
1172
        {
1173
            $this->payment_date = $paymentDate;
1174
1175
            return $this;
1176
        }
1177
1178
        /**
1179
         * Get paymentDate.
1180
         *
1181
         * @return \DateTime|null
1182
         */
1183
        public function getPaymentDate()
1184
        {
1185
            return $this->payment_date;
1186
        }
1187
1188
        /**
1189
         * Get currencyCode.
1190
         *
1191
         * @return string
1192
         */
1193
        public function getCurrencyCode()
1194
        {
1195
            return $this->currency_code;
1196
        }
1197
1198
        /**
1199
         * Set currencyCode.
1200
         *
1201
         * @param string|null $currencyCode
1202
         *
1203
         * @return $this
1204
         */
1205
        public function setCurrencyCode($currencyCode = null)
1206
        {
1207
            $this->currency_code = $currencyCode;
1208
1209
            return $this;
1210
        }
1211
1212
        /**
1213
         * @return null|string
1214
         */
1215
        public function getCompleteMessage()
1216
        {
1217
            return $this->complete_message;
1218
        }
1219
1220
        /**
1221
         * @param null|string $complete_message
1222
         *
1223
         * @return $this
1224
         */
1225
        public function setCompleteMessage($complete_message = null)
1226
        {
1227
            $this->complete_message = $complete_message;
1228
1229
            return $this;
1230
        }
1231
1232
        /**
1233
         * @param null|string $complete_message
1234
         *
1235
         * @return $this
1236
         */
1237
        public function appendCompleteMessage($complete_message = null)
1238
        {
1239
            $this->complete_message .= $complete_message;
1240
1241
            return $this;
1242
        }
1243
1244
        /**
1245
         * @return null|string
1246
         */
1247
        public function getCompleteMailMessage()
1248
        {
1249
            return $this->complete_mail_message;
1250
        }
1251
1252
        /**
1253
         * @param null|string $complete_mail_message
1254
         *
1255
         * @return
1256
         */
1257
        public function setCompleteMailMessage($complete_mail_message = null)
1258
        {
1259
            $this->complete_mail_message = $complete_mail_message;
1260
1261
            return $this;
1262
        }
1263
1264
        /**
1265
         * @param null|string $complete_mail_message
1266
         *
1267
         * @return
1268
         */
1269
        public function appendCompleteMailMessage($complete_mail_message = null)
1270
        {
1271
            $this->complete_mail_message .= $complete_mail_message;
1272
1273
            return $this;
1274
        }
1275
1276
        /**
1277
         * 商品の受注明細を取得
1278
         *
1279
         * @return OrderItem[]
1280
         */
1281
        public function getProductOrderItems()
1282
        {
1283
            $sio = new OrderItemCollection($this->OrderItems->toArray());
1284
1285
            return array_values($sio->getProductClasses()->toArray());
1286
        }
1287
1288
        /**
1289
         * Add orderItem.
1290
         *
1291
         * @param \Eccube\Entity\OrderItem $OrderItem
1292
         *
1293
         * @return Order
1294
         */
1295
        public function addOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1296
        {
1297
            $this->OrderItems[] = $OrderItem;
1298
1299
            return $this;
1300
        }
1301
1302
        /**
1303
         * Remove orderItem.
1304
         *
1305
         * @param \Eccube\Entity\OrderItem $OrderItem
1306
         *
1307
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1308
         */
1309
        public function removeOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1310
        {
1311
            return $this->OrderItems->removeElement($OrderItem);
1312
        }
1313
1314
        /**
1315
         * Get orderItems.
1316
         *
1317
         * @return \Doctrine\Common\Collections\Collection|OrderItem[]
1318
         */
1319
        public function getOrderItems()
1320
        {
1321
            return $this->OrderItems;
1322
        }
1323
1324
        /**
1325
         * Sorted to getOrderItems()
1326
         *
1327
         * @return ItemCollection
1328
         */
1329
        public function getItems()
1330
        {
1331
            return (new ItemCollection($this->getOrderItems()))->sort();
1332
        }
1333
1334
        /**
1335
         * Add shipping.
1336
         *
1337
         * @param \Eccube\Entity\Shipping $Shipping
1338
         *
1339
         * @return Order
1340
         */
1341
        public function addShipping(\Eccube\Entity\Shipping $Shipping)
1342
        {
1343
            $this->Shippings[] = $Shipping;
1344
1345
            return $this;
1346
        }
1347
1348
        /**
1349
         * Remove shipping.
1350
         *
1351
         * @param \Eccube\Entity\Shipping $Shipping
1352
         *
1353
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1354
         */
1355
        public function removeShipping(\Eccube\Entity\Shipping $Shipping)
1356
        {
1357
            return $this->Shippings->removeElement($Shipping);
1358
        }
1359
1360
        /**
1361
         * Get shippings.
1362
         *
1363
         * @return \Doctrine\Common\Collections\Collection|\Eccube\Entity\Shipping[]
1364
         */
1365
        public function getShippings()
1366
        {
1367
            $criteria = Criteria::create()
1368
            ->orderBy(['name01' => Criteria::ASC, 'name02' => Criteria::ASC, 'id' => Criteria::ASC]);
1369
1370
            return $this->Shippings->matching($criteria);
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Doctrine\Common\Collections\Collection as the method matching() does only exist in the following implementations of said interface: Doctrine\Common\Collections\ArrayCollection, Doctrine\ORM\LazyCriteriaCollection, Doctrine\ORM\PersistentCollection, Eccube\Service\Calculator\OrderItemCollection, Eccube\Service\PurchaseFlow\ItemCollection.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
1371
        }
1372
1373
        /**
1374
         * Add mailHistory.
1375
         *
1376
         * @param \Eccube\Entity\MailHistory $mailHistory
1377
         *
1378
         * @return Order
1379
         */
1380
        public function addMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1381
        {
1382
            $this->MailHistories[] = $mailHistory;
1383
1384
            return $this;
1385
        }
1386
1387
        /**
1388
         * Remove mailHistory.
1389
         *
1390
         * @param \Eccube\Entity\MailHistory $mailHistory
1391
         *
1392
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1393
         */
1394
        public function removeMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1395
        {
1396
            return $this->MailHistories->removeElement($mailHistory);
1397
        }
1398
1399
        /**
1400
         * Get mailHistories.
1401
         *
1402
         * @return \Doctrine\Common\Collections\Collection
1403
         */
1404
        public function getMailHistories()
1405
        {
1406
            return $this->MailHistories;
1407
        }
1408
1409
        /**
1410
         * Set customer.
1411
         *
1412
         * @param \Eccube\Entity\Customer|null $customer
1413
         *
1414
         * @return Order
1415
         */
1416
        public function setCustomer(\Eccube\Entity\Customer $customer = null)
1417
        {
1418
            $this->Customer = $customer;
1419
1420
            return $this;
1421
        }
1422
1423
        /**
1424
         * Get customer.
1425
         *
1426
         * @return \Eccube\Entity\Customer|null
1427
         */
1428
        public function getCustomer()
1429
        {
1430
            return $this->Customer;
1431
        }
1432
1433
        /**
1434
         * Set country.
1435
         *
1436
         * @param \Eccube\Entity\Master\Country|null $country
1437
         *
1438
         * @return Order
1439
         */
1440
        public function setCountry(\Eccube\Entity\Master\Country $country = null)
1441
        {
1442
            $this->Country = $country;
1443
1444
            return $this;
1445
        }
1446
1447
        /**
1448
         * Get country.
1449
         *
1450
         * @return \Eccube\Entity\Master\Country|null
1451
         */
1452
        public function getCountry()
1453
        {
1454
            return $this->Country;
1455
        }
1456
1457
        /**
1458
         * Set pref.
1459
         *
1460
         * @param \Eccube\Entity\Master\Pref|null $pref
1461
         *
1462
         * @return Order
1463
         */
1464
        public function setPref(\Eccube\Entity\Master\Pref $pref = null)
1465
        {
1466
            $this->Pref = $pref;
1467
1468
            return $this;
1469
        }
1470
1471
        /**
1472
         * Get pref.
1473
         *
1474
         * @return \Eccube\Entity\Master\Pref|null
1475
         */
1476
        public function getPref()
1477
        {
1478
            return $this->Pref;
1479
        }
1480
1481
        /**
1482
         * Set sex.
1483
         *
1484
         * @param \Eccube\Entity\Master\Sex|null $sex
1485
         *
1486
         * @return Order
1487
         */
1488
        public function setSex(\Eccube\Entity\Master\Sex $sex = null)
1489
        {
1490
            $this->Sex = $sex;
1491
1492
            return $this;
1493
        }
1494
1495
        /**
1496
         * Get sex.
1497
         *
1498
         * @return \Eccube\Entity\Master\Sex|null
1499
         */
1500
        public function getSex()
1501
        {
1502
            return $this->Sex;
1503
        }
1504
1505
        /**
1506
         * Set job.
1507
         *
1508
         * @param \Eccube\Entity\Master\Job|null $job
1509
         *
1510
         * @return Order
1511
         */
1512
        public function setJob(\Eccube\Entity\Master\Job $job = null)
1513
        {
1514
            $this->Job = $job;
1515
1516
            return $this;
1517
        }
1518
1519
        /**
1520
         * Get job.
1521
         *
1522
         * @return \Eccube\Entity\Master\Job|null
1523
         */
1524
        public function getJob()
1525
        {
1526
            return $this->Job;
1527
        }
1528
1529
        /**
1530
         * Set payment.
1531
         *
1532
         * @param \Eccube\Entity\Payment|null $payment
1533
         *
1534
         * @return Order
1535
         */
1536
        public function setPayment(\Eccube\Entity\Payment $payment = null)
1537
        {
1538
            $this->Payment = $payment;
1539
1540
            return $this;
1541
        }
1542
1543
        /**
1544
         * Get payment.
1545
         *
1546
         * @return \Eccube\Entity\Payment|null
1547
         */
1548
        public function getPayment()
1549
        {
1550
            return $this->Payment;
1551
        }
1552
1553
        /**
1554
         * Set deviceType.
1555
         *
1556
         * @param \Eccube\Entity\Master\DeviceType|null $deviceType
1557
         *
1558
         * @return Order
1559
         */
1560
        public function setDeviceType(\Eccube\Entity\Master\DeviceType $deviceType = null)
1561
        {
1562
            $this->DeviceType = $deviceType;
1563
1564
            return $this;
1565
        }
1566
1567
        /**
1568
         * Get deviceType.
1569
         *
1570
         * @return \Eccube\Entity\Master\DeviceType|null
1571
         */
1572
        public function getDeviceType()
1573
        {
1574
            return $this->DeviceType;
1575
        }
1576
1577
        /**
1578
         * Set customerOrderStatus.
1579
         *
1580
         * @param \Eccube\Entity\Master\CustomerOrderStatus|null $customerOrderStatus
1581
         *
1582
         * @return Order
1583
         */
1584
        public function setCustomerOrderStatus(\Eccube\Entity\Master\CustomerOrderStatus $customerOrderStatus = null)
1585
        {
1586
            $this->CustomerOrderStatus = $customerOrderStatus;
1587
1588
            return $this;
1589
        }
1590
1591
        /**
1592
         * Get customerOrderStatus.
1593
         *
1594
         * @return \Eccube\Entity\Master\CustomerOrderStatus|null
1595
         */
1596
        public function getCustomerOrderStatus()
1597
        {
1598
            return $this->CustomerOrderStatus;
1599
        }
1600
1601
        /**
1602
         * Set orderStatus.
1603
         *
1604
         * @param \Eccube\Entity\Master\OrderStatus|null $orderStatus
1605
         *
1606
         * @return Order
1607
         */
1608
        public function setOrderStatus(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
1609
        {
1610
            $this->OrderStatus = $orderStatus;
1611
1612
            return $this;
1613
        }
1614
1615
        /**
1616
         * Get orderStatus.
1617
         *
1618
         * @return \Eccube\Entity\Master\OrderStatus|null
1619
         */
1620
        public function getOrderStatus()
1621
        {
1622
            return $this->OrderStatus;
1623
        }
1624
1625
        /**
1626
         * @param ItemInterface $item
1627
         */
1628
        public function addItem(ItemInterface $item)
1629
        {
1630
            $this->OrderItems->add($item);
1631
        }
1632
1633
        public function getQuantity()
1634
        {
1635
            $quantity = 0;
1636
            foreach ($this->getItems() as $item) {
1637
                $quantity += $item->getQuantity();
1638
            }
1639
1640
            return $quantity;
1641
        }
1642
    }
1643
}
1644