Failed Conditions
Pull Request — 4.0 (#4302)
by chihiro
04:25
created

Order::removeShipping()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
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\Common\Collections\Criteria;
18
use Doctrine\ORM\Mapping as ORM;
19
use Eccube\Entity\Master\TaxType;
20
use Eccube\Service\Calculator\OrderItemCollection;
21
use Eccube\Service\PurchaseFlow\ItemCollection;
22 1
23
if (!class_exists('\Eccube\Entity\Order')) {
24
    /**
25
     * Order
26
     *
27
     * @ORM\Table(name="dtb_order", indexes={
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
     *  uniqueConstraints={
35
     *     @ORM\UniqueConstraint(name="dtb_order_pre_order_id_idx", columns={"pre_order_id"})
36
     *  })
37
     * @ORM\InheritanceType("SINGLE_TABLE")
38
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
39
     * @ORM\HasLifecycleCallbacks()
40
     * @ORM\Entity(repositoryClass="Eccube\Repository\OrderRepository")
41
     */
42
    class Order extends \Eccube\Entity\AbstractEntity implements PurchaseInterface, ItemHolderInterface
43
    {
44
        use NameTrait, PointTrait;
45
46
        /**
47
         * 課税対象の明細を返す.
48 65
         *
49
         * @return array
50 65
         */
51
        public function getTaxableItems()
52
        {
53 65
            $Items = [];
54 64
55 62
            foreach ($this->OrderItems as $Item) {
56 62
                if ($Item->getTaxType()->getId() == TaxType::TAXATION) {
57 62
                    $Items[] = $Item;
58
                }
59 64
            }
60
61
            return $Items;
62
        }
63 65
64
        /**
65
         * 課税対象の明細の合計金額を返す.
66
         * 商品合計 + 送料 + 手数料 + 値引き(課税).
67
         */
68
        public function getTaxableTotal()
69
        {
70
            $total = 0;
71
72
            foreach ($this->getTaxableItems() as $Item) {
73
                $total += $Item->getTotalPrice();
74
            }
75
76
            return $total;
77
        }
78
79
        /**
80
         * 課税対象の明細の合計金額を、税率ごとに集計する.
81
         *
82
         * @return array
83
         */
84
        public function getTaxableTotalByTaxRate()
85
        {
86
            $total = [];
87
88
            foreach ($this->getTaxableItems() as $Item) {
89 1
                    $totalPrice = $Item->getTotalPrice();
90
                    $taxRate = $Item->getTaxRate();
91 1
                    $total[$taxRate] = isset($total[$taxRate])
92 1
                        ? $total[$taxRate] + $totalPrice
93
                        : $totalPrice;
94 1
            }
95 1
96 1
            krsort($total);
97
98
            return $total;
99
        }
100 1
101
        /**
102
         * 課税対象の値引き明細を返す.
103
         *
104
         * @return array
105
         */
106
        public function getTaxableDiscountItems()
107
        {
108 1
            return array_filter($this->getTaxableItems(), function(OrderItem $Item) {
109
                return $Item->isDiscount();
110 1
            });
111 1
        }
112
113 1
        /**
114 1
         * 課税対象の値引き金額合計を返す.
115 1
         *
116
         * @return mixed
117
         */
118 1
        public function getTaxableDiscount()
119 1
        {
120 1
            return array_reduce($this->getTaxableDiscountItems(), function ($sum, OrderItem $Item) {
121
                return $sum += $Item->getTotalPrice();
122
            }, 0);
123 1
        }
124
125 1
        /**
126 1
         * 非課税・不課税の値引き明細を返す.
127 1
         *
128 1
         * @return array
129 1
         */
130 1
        public function getTaxFreeDiscountItems()
131 1
        {
132 1
            return array_filter($this->OrderItems->toArray(), function(OrderItem $Item) {
133
                return $Item->isPoint() || ($Item->isDiscount() && $Item->getTaxType()->getId() != TaxType::TAXATION);
134
            });
135
        }
136 1
137
        /**
138
         * 複数配送かどうかの判定を行う.
139
         *
140
         * @return boolean
141
         */
142
        public function isMultiple()
143
        {
144
            $Shippings = [];
145
            // クエリビルダ使用時に絞り込まれる場合があるため,
146 1
            // getShippingsではなくOrderItem経由でShippingを取得する.
147
            foreach ($this->getOrderItems() as $OrderItem) {
148 1
                if ($Shipping = $OrderItem->getShipping()) {
149
                    $id = $Shipping->getId();
150 1
                    if (isset($Shippings[$id])) {
151
                        continue;
152
                    }
153
                    $Shippings[$id] = $Shipping;
154
                }
155
            }
156
157
            return count($Shippings) > 1 ? true : false;
158
        }
159
160
        /**
161
         * 対象となるお届け先情報を取得
162
         *
163
         * @param integer $shippingId
164
         *
165
         * @return \Eccube\Entity\Shipping|null
166
         */
167
        public function findShipping($shippingId)
168
        {
169
            foreach ($this->getShippings() as $Shipping) {
170
                if ($Shipping->getId() == $shippingId) {
171
                    return $Shipping;
172
                }
173
            }
174
175
            return null;
176
        }
177
178
        /**
179
         * この注文の保持する販売種別を取得します.
180
         *
181
         * @return \Eccube\Entity\Master\SaleType[] 一意な販売種別の配列
182
         */
183
        public function getSaleTypes()
184
        {
185
            $saleTypes = [];
186
            foreach ($this->getOrderItems() as $OrderItem) {
187
                /* @var $ProductClass \Eccube\Entity\ProductClass */
188
                $ProductClass = $OrderItem->getProductClass();
189
                if ($ProductClass) {
190
                    $saleTypes[] = $ProductClass->getSaleType();
191
                }
192
            }
193
194
            return array_unique($saleTypes);
195
        }
196
197
        /**
198
         * 同じ規格の商品の個数をまとめた受注明細を取得
199
         *
200
         * @return OrderItem[]
201
         */
202
        public function getMergedProductOrderItems()
203
        {
204
            $ProductOrderItems = $this->getProductOrderItems();
205
            $orderItemArray = [];
206
            /** @var OrderItem $ProductOrderItem */
207
            foreach ($ProductOrderItems as $ProductOrderItem) {
208
                $productClassId = $ProductOrderItem->getProductClass()->getId();
209
                if (array_key_exists($productClassId, $orderItemArray)) {
210
                    // 同じ規格の商品がある場合は個数をまとめる
211
                    /** @var ItemInterface $OrderItem */
212
                    $OrderItem = $orderItemArray[$productClassId];
213
                    $quantity = $OrderItem->getQuantity() + $ProductOrderItem->getQuantity();
214
                    $OrderItem->setQuantity($quantity);
215
                } else {
216
                    // 新規規格の商品は新しく追加する
217
                    $OrderItem = new OrderItem();
218
                    $OrderItem->setOrder($ProductOrderItem->getOrder());
219
                    $OrderItem
220
                    ->setProduct($ProductOrderItem->getProduct())
221
                    ->setProductName($ProductOrderItem->getProductName())
222
                    ->setProductCode($ProductOrderItem->getProductCode())
223
                    ->setClassCategoryName1($ProductOrderItem->getClassCategoryName1())
224
                    ->setClassCategoryName2($ProductOrderItem->getClassCategoryName2())
225
                    ->setPrice($ProductOrderItem->getPrice())
226
                    ->setTax($ProductOrderItem->getTax())
227
                    ->setTaxRate($ProductOrderItem->getTaxRate())
228
                    ->setQuantity($ProductOrderItem->getQuantity());
229
                    $orderItemArray[$productClassId] = $OrderItem;
230
                }
231
            }
232
233
            return array_values($orderItemArray);
234
        }
235
236
        /**
237
         * 合計金額を計算
238
         *
239
         * @return string
240
         *
241
         * @deprecated
242
         */
243
        public function getTotalPrice()
244
        {
245
            @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...
246
247
            return $this->getSubtotal() + $this->getCharge() + $this->getDeliveryFeeTotal() - $this->getDiscount();
0 ignored issues
show
Deprecated Code introduced by
The method Eccube\Entity\Order::getDiscount() has been deprecated with message: 4.0.3 から値引きは課税値引きと 非課税・不課税の値引きの2種に分かれる. 課税値引きについてはgetTaxableDiscountを利用してください.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
248
//        return $this->getSubtotal() + $this->getCharge() - $this->getDiscount();
249
        }
250
251
        /**
252
         * @var integer
253
         *
254
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
255
         * @ORM\Id
256
         * @ORM\GeneratedValue(strategy="IDENTITY")
257
         */
258
        private $id;
259
260
        /**
261
         * @var string|null
262
         *
263
         * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true)
264
         */
265
        private $pre_order_id;
266
267
        /**
268
         * @var string|null
269
         *
270
         * @ORM\Column(name="order_no", type="string", length=255, nullable=true)
271
         */
272
        private $order_no;
273
274
        /**
275
         * @var string|null
276
         *
277
         * @ORM\Column(name="message", type="string", length=4000, nullable=true)
278
         */
279
        private $message;
280
281
        /**
282
         * @var string|null
283
         *
284
         * @ORM\Column(name="name01", type="string", length=255)
285
         */
286
        private $name01;
287
288
        /**
289
         * @var string|null
290
         *
291
         * @ORM\Column(name="name02", type="string", length=255)
292
         */
293
        private $name02;
294
295
        /**
296
         * @var string|null
297
         *
298
         * @ORM\Column(name="kana01", type="string", length=255, nullable=true)
299
         */
300
        private $kana01;
301
302
        /**
303
         * @var string|null
304
         *
305
         * @ORM\Column(name="kana02", type="string", length=255, nullable=true)
306
         */
307
        private $kana02;
308
309
        /**
310
         * @var string|null
311
         *
312
         * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
313
         */
314
        private $company_name;
315
316
        /**
317
         * @var string|null
318
         *
319
         * @ORM\Column(name="email", type="string", length=255, nullable=true)
320
         */
321
        private $email;
322
323
        /**
324
         * @var string|null
325
         *
326
         * @ORM\Column(name="phone_number", type="string", length=14, nullable=true)
327
         */
328
        private $phone_number;
329
330
        /**
331
         * @var string|null
332
         *
333
         * @ORM\Column(name="postal_code", type="string", length=8, nullable=true)
334
         */
335
        private $postal_code;
336
337
        /**
338
         * @var string|null
339
         *
340
         * @ORM\Column(name="addr01", type="string", length=255, nullable=true)
341
         */
342
        private $addr01;
343
344
        /**
345
         * @var string|null
346
         *
347
         * @ORM\Column(name="addr02", type="string", length=255, nullable=true)
348
         */
349
        private $addr02;
350
351
        /**
352
         * @var \DateTime|null
353
         *
354
         * @ORM\Column(name="birth", type="datetimetz", nullable=true)
355
         */
356
        private $birth;
357
358
        /**
359
         * @var string
360
         *
361
         * @ORM\Column(name="subtotal", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
362
         */
363
        private $subtotal = 0;
364
365
        /**
366
         * @var string
367
         *
368
         * @ORM\Column(name="discount", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
369
         */
370
        private $discount = 0;
371
372
        /**
373
         * @var string
374
         *
375
         * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
376
         */
377
        private $delivery_fee_total = 0;
378
379
        /**
380
         * @var string
381
         *
382
         * @ORM\Column(name="charge", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
383
         */
384
        private $charge = 0;
385
386
        /**
387
         * @var string
388
         *
389
         * @ORM\Column(name="tax", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
390
         *
391
         * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
392
         */
393
        private $tax = 0;
394
395
        /**
396
         * @var string
397
         *
398
         * @ORM\Column(name="total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
399
         */
400
        private $total = 0;
401
402
        /**
403
         * @var string
404
         *
405
         * @ORM\Column(name="payment_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
406
         */
407
        private $payment_total = 0;
408
409
        /**
410
         * @var string|null
411
         *
412
         * @ORM\Column(name="payment_method", type="string", length=255, nullable=true)
413
         */
414
        private $payment_method;
415
416
        /**
417
         * @var string|null
418
         *
419
         * @ORM\Column(name="note", type="string", length=4000, nullable=true)
420
         */
421
        private $note;
422
423
        /**
424
         * @var \DateTime
425
         *
426
         * @ORM\Column(name="create_date", type="datetimetz")
427
         */
428
        private $create_date;
429
430
        /**
431
         * @var \DateTime
432
         *
433
         * @ORM\Column(name="update_date", type="datetimetz")
434
         */
435
        private $update_date;
436
437
        /**
438
         * @var \DateTime|null
439
         *
440
         * @ORM\Column(name="order_date", type="datetimetz", nullable=true)
441
         */
442
        private $order_date;
443
444
        /**
445
         * @var \DateTime|null
446
         *
447
         * @ORM\Column(name="payment_date", type="datetimetz", nullable=true)
448
         */
449
        private $payment_date;
450
451
        /**
452
         * @var string|null
453
         *
454
         * @ORM\Column(name="currency_code", type="string", nullable=true)
455
         */
456
        private $currency_code;
457
458
        /**
459
         * 注文完了画面に表示するメッセージ
460
         *
461
         * プラグインから注文完了時にメッセージを表示したい場合, このフィールドにセットすることで, 注文完了画面で表示されます。
462
         * 複数のプラグインから利用されるため, appendCompleteMesssage()で追加してください.
463
         * 表示する際にHTMLは利用可能です。
464
         *
465
         * @var string|null
466
         *
467
         * @ORM\Column(name="complete_message", type="text", nullable=true)
468
         */
469
        private $complete_message;
470
471
        /**
472
         * 注文完了メールに表示するメッセージ
473
         *
474
         * プラグインから注文完了メールにメッセージを表示したい場合, このフィールドにセットすることで, 注文完了メールで表示されます。
475
         * 複数のプラグインから利用されるため, appendCompleteMailMesssage()で追加してください.
476
         *
477
         * @var string|null
478
         *
479
         * @ORM\Column(name="complete_mail_message", type="text", nullable=true)
480
         */
481
        private $complete_mail_message;
482
483
        /**
484
         * @var \Doctrine\Common\Collections\Collection|OrderItem[]
485
         *
486
         * @ORM\OneToMany(targetEntity="Eccube\Entity\OrderItem", mappedBy="Order", cascade={"persist","remove"})
487
         */
488
        private $OrderItems;
489
490
        /**
491
         * @var \Doctrine\Common\Collections\Collection|Shipping[]
492
         *
493
         * @ORM\OneToMany(targetEntity="Eccube\Entity\Shipping", mappedBy="Order", cascade={"persist","remove"})
494
         */
495
        private $Shippings;
496
497
        /**
498
         * @var \Doctrine\Common\Collections\Collection
499
         *
500
         * @ORM\OneToMany(targetEntity="Eccube\Entity\MailHistory", mappedBy="Order", cascade={"remove"})
501 356
         * @ORM\OrderBy({
502
         *     "send_date"="DESC"
503 356
         * })
504 356
         */
505 356
        private $MailHistories;
506 356
507 356
        /**
508 356
         * @var \Eccube\Entity\Customer
509 356
         *
510 356
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer", inversedBy="Orders")
511
         * @ORM\JoinColumns({
512
         *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
513 356
         * })
514 356
         */
515 356
        private $Customer;
516
517
        /**
518
         * @var \Eccube\Entity\Master\Country
519
         *
520
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Country")
521 7
         * @ORM\JoinColumns({
522
         *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
523 7
         * })
524 7
         */
525 4
        private $Country;
526
527 7
        /**
528
         * @var \Eccube\Entity\Master\Pref
529
         *
530
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Pref")
531
         * @ORM\JoinColumns({
532
         *   @ORM\JoinColumn(name="pref_id", referencedColumnName="id")
533
         * })
534
         */
535 124
        private $Pref;
536
537 124
        /**
538
         * @var \Eccube\Entity\Master\Sex
539
         *
540
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Sex")
541
         * @ORM\JoinColumns({
542
         *   @ORM\JoinColumn(name="sex_id", referencedColumnName="id")
543
         * })
544
         */
545
        private $Sex;
546
547 205
        /**
548
         * @var \Eccube\Entity\Master\Job
549 205
         *
550
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Job")
551 205
         * @ORM\JoinColumns({
552
         *   @ORM\JoinColumn(name="job_id", referencedColumnName="id")
553
         * })
554
         */
555
        private $Job;
556
557
        /**
558
         * @var \Eccube\Entity\Payment
559 53
         *
560
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Payment")
561 53
         * @ORM\JoinColumns({
562
         *   @ORM\JoinColumn(name="payment_id", referencedColumnName="id")
563
         * })
564
         */
565
        private $Payment;
566
567
        /**
568
         * @var \Eccube\Entity\Master\DeviceType
569
         *
570
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\DeviceType")
571 227
         * @ORM\JoinColumns({
572
         *   @ORM\JoinColumn(name="device_type_id", referencedColumnName="id")
573 227
         * })
574
         */
575 227
        private $DeviceType;
576
577
        /**
578
         * OrderStatusより先にプロパティを定義しておかないとセットされなくなる
579
         *
580
         * @var \Eccube\Entity\Master\CustomerOrderStatus
581
         *
582
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\CustomerOrderStatus")
583 97
         * @ORM\JoinColumns({
584
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
585 97
         * })
586
         */
587
        private $CustomerOrderStatus;
588
589
        /**
590
         * OrderStatusより先にプロパティを定義しておかないとセットされなくなる
591
         *
592
         * @var \Eccube\Entity\Master\OrderStatusColor
593
         *
594
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatusColor")
595 181
         * @ORM\JoinColumns({
596
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
597 181
         * })
598
         */
599 181
        private $OrderStatusColor;
600
601
        /**
602
         * @var \Eccube\Entity\Master\OrderStatus
603
         *
604
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatus")
605
         * @ORM\JoinColumns({
606
         *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
607 81
         * })
608
         */
609 81
        private $OrderStatus;
610
611
        /**
612
         * Constructor
613
         */
614
        public function __construct(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
615
        {
616
            $this->setDiscount(0)
0 ignored issues
show
Deprecated Code introduced by
The method Eccube\Entity\Order::setTax() has been deprecated with message: 明細ごとに集計した税額と差異が発生する場合があるため非推奨

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
617
            ->setSubtotal(0)
618
            ->setTotal(0)
619 18
            ->setPaymentTotal(0)
620
            ->setCharge(0)
621 18
            ->setTax(0)
622
            ->setDeliveryFeeTotal(0)
623 18
            ->setOrderStatus($orderStatus)
624
        ;
625
626
            $this->OrderItems = new \Doctrine\Common\Collections\ArrayCollection();
627
            $this->Shippings = new \Doctrine\Common\Collections\ArrayCollection();
628
            $this->MailHistories = new \Doctrine\Common\Collections\ArrayCollection();
629
        }
630
631 80
        /**
632
         * Clone
633 80
         */
634
        public function __clone()
635
        {
636
            $OriginOrderItems = $this->OrderItems;
0 ignored issues
show
Unused Code introduced by
$OriginOrderItems is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
637
            $OrderItems = new ArrayCollection();
638
            foreach ($this->OrderItems as $OrderItem) {
639
                $OrderItems->add(clone $OrderItem);
640
            }
641
            $this->OrderItems = $OrderItems;
642
643 18
//            // ShippingとOrderItemが循環参照するため, 手動でヒモ付を変更する.
644
//            $Shippings = new ArrayCollection();
645 18
//            foreach ($this->Shippings as $Shipping) {
646
//                $CloneShipping = clone $Shipping;
647 18
//                foreach ($OriginOrderItems as $OrderItem) {
648
//                    //$CloneShipping->removeOrderItem($OrderItem);
649
//                }
650
//                foreach ($this->OrderItems as $OrderItem) {
651
//                    if ($OrderItem->getShipping() && $OrderItem->getShipping()->getId() == $Shipping->getId()) {
652
//                        $OrderItem->setShipping($CloneShipping);
653
//                    }
654
//                    $CloneShipping->addOrderItem($OrderItem);
655 80
//                }
656
//                $Shippings->add($CloneShipping);
657 80
//            }
658
//            $this->Shippings = $Shippings;
659
        }
660
661
        /**
662
         * Get id.
663
         *
664
         * @return int
665
         */
666
        public function getId()
667 19
        {
668
            return $this->id;
669 19
        }
670
671 19
        /**
672
         * Set preOrderId.
673
         *
674
         * @param string|null $preOrderId
675
         *
676
         * @return Order
677
         */
678
        public function setPreOrderId($preOrderId = null)
679 70
        {
680
            $this->pre_order_id = $preOrderId;
681 70
682
            return $this;
683
        }
684
685
        /**
686
         * Get preOrderId.
687
         *
688
         * @return string|null
689
         */
690
        public function getPreOrderId()
691 19
        {
692
            return $this->pre_order_id;
693 19
        }
694
695 19
        /**
696
         * Set orderNo
697
         *
698
         * @param string|null $orderNo
699
         *
700
         * @return Order
701
         */
702
        public function setOrderNo($orderNo = null)
703 70
        {
704
            $this->order_no = $orderNo;
705 70
706
            return $this;
707
        }
708
709
        /**
710
         * Get orderNo
711
         *
712
         * @return string|null
713
         */
714
        public function getOrderNo()
715 16
        {
716
            return $this->order_no;
717 16
        }
718
719 16
        /**
720
         * Set message.
721
         *
722
         * @param string|null $message
723
         *
724
         * @return Order
725
         */
726
        public function setMessage($message = null)
727 71
        {
728
            $this->message = $message;
729 71
730
            return $this;
731
        }
732
733
        /**
734
         * Get message.
735
         *
736
         * @return string|null
737
         */
738
        public function getMessage()
739 16
        {
740
            return $this->message;
741 16
        }
742
743 16
        /**
744
         * Set name01.
745
         *
746
         * @param string|null $name01
747
         *
748
         * @return Order
749
         */
750
        public function setName01($name01 = null)
751 74
        {
752
            $this->name01 = $name01;
753 74
754
            return $this;
755
        }
756
757
        /**
758
         * Get name01.
759
         *
760
         * @return string|null
761
         */
762
        public function getName01()
763 17
        {
764
            return $this->name01;
765 17
        }
766
767 17
        /**
768
         * Set name02.
769
         *
770
         * @param string|null $name02
771
         *
772
         * @return Order
773
         */
774
        public function setName02($name02 = null)
775 70
        {
776
            $this->name02 = $name02;
777 70
778
            return $this;
779
        }
780
781
        /**
782
         * Get name02.
783
         *
784
         * @return string|null
785
         */
786
        public function getName02()
787 16
        {
788
            return $this->name02;
789 16
        }
790
791 16
        /**
792
         * Set kana01.
793
         *
794
         * @param string|null $kana01
795
         *
796
         * @return Order
797
         */
798
        public function setKana01($kana01 = null)
799 70
        {
800
            $this->kana01 = $kana01;
801 70
802
            return $this;
803
        }
804
805
        /**
806
         * Get kana01.
807
         *
808
         * @return string|null
809
         */
810
        public function getKana01()
811 16
        {
812
            return $this->kana01;
813 16
        }
814
815 16
        /**
816
         * Set kana02.
817
         *
818
         * @param string|null $kana02
819
         *
820
         * @return Order
821
         */
822
        public function setKana02($kana02 = null)
823 73
        {
824
            $this->kana02 = $kana02;
825 73
826
            return $this;
827
        }
828
829
        /**
830
         * Get kana02.
831
         *
832
         * @return string|null
833
         */
834
        public function getKana02()
835 16
        {
836
            return $this->kana02;
837 16
        }
838
839 16
        /**
840
         * Set companyName.
841
         *
842
         * @param string|null $companyName
843
         *
844
         * @return Order
845
         */
846
        public function setCompanyName($companyName = null)
847 73
        {
848
            $this->company_name = $companyName;
849 73
850
            return $this;
851
        }
852
853
        /**
854
         * Get companyName.
855
         *
856
         * @return string|null
857
         */
858
        public function getCompanyName()
859 5
        {
860
            return $this->company_name;
861 5
        }
862
863 5
        /**
864
         * Set email.
865
         *
866
         * @param string|null $email
867
         *
868
         * @return Order
869
         */
870
        public function setEmail($email = null)
871 3
        {
872
            $this->email = $email;
873 3
874
            return $this;
875
        }
876
877
        /**
878
         * Get email.
879
         *
880
         * @return string|null
881
         */
882
        public function getEmail()
883 356
        {
884
            return $this->email;
885 356
        }
886
887 356
        /**
888
         * Set phone_number.
889
         *
890
         * @param string|null $phone_number
891
         *
892
         * @return Order
893
         */
894
        public function setPhoneNumber($phone_number = null)
895 60
        {
896
            $this->phone_number = $phone_number;
897 60
898
            return $this;
899
        }
900
901
        /**
902
         * Get phone_number.
903
         *
904
         * @return string|null
905
         */
906
        public function getPhoneNumber()
907 356
        {
908
            return $this->phone_number;
909 356
        }
910
911 356
        /**
912
         * Set postal_code.
913
         *
914
         * @param string|null $postal_code
915
         *
916
         * @return Order
917
         */
918
        public function setPostalCode($postal_code = null)
919 212
        {
920
            $this->postal_code = $postal_code;
921 212
922
            return $this;
923
        }
924
925
        /**
926
         * Get postal_code.
927
         *
928
         * @return string|null
929
         */
930
        public function getPostalCode()
931 356
        {
932
            return $this->postal_code;
933 356
        }
934
935 356
        /**
936
         * Set addr01.
937
         *
938
         * @param string|null $addr01
939
         *
940
         * @return Order
941
         */
942
        public function setAddr01($addr01 = null)
943 75
        {
944
            $this->addr01 = $addr01;
945 75
946
            return $this;
947
        }
948
949
        /**
950
         * Get addr01.
951
         *
952
         * @return string|null
953
         */
954
        public function getAddr01()
955 356
        {
956
            return $this->addr01;
957 356
        }
958
959 356
        /**
960
         * Set addr02.
961
         *
962
         * @param string|null $addr02
963
         *
964
         * @return Order
965
         */
966
        public function setAddr02($addr02 = null)
967 212
        {
968
            $this->addr02 = $addr02;
969 212
970
            return $this;
971
        }
972
973
        /**
974
         * Get addr02.
975
         *
976
         * @return string|null
977
         */
978
        public function getAddr02()
979 356
        {
980
            return $this->addr02;
981 356
        }
982
983 356
        /**
984
         * Set birth.
985
         *
986
         * @param \DateTime|null $birth
987
         *
988
         * @return Order
989
         */
990
        public function setBirth($birth = null)
991 16
        {
992
            $this->birth = $birth;
993 16
994
            return $this;
995
        }
996
997
        /**
998
         * Get birth.
999
         *
1000
         * @return \DateTime|null
1001
         */
1002
        public function getBirth()
1003 356
        {
1004
            return $this->birth;
1005 356
        }
1006
1007 356
        /**
1008
         * Set subtotal.
1009
         *
1010
         * @param string $subtotal
1011
         *
1012
         * @return Order
1013
         */
1014
        public function setSubtotal($subtotal)
1015 237
        {
1016
            $this->subtotal = $subtotal;
1017 237
1018
            return $this;
1019
        }
1020
1021
        /**
1022
         * Get subtotal.
1023
         *
1024
         * @return string
1025
         */
1026
        public function getSubtotal()
1027 356
        {
1028
            return $this->subtotal;
1029 356
        }
1030
1031 356
        /**
1032
         * Set discount.
1033
         *
1034
         * @param string $discount
1035
         *
1036
         * @return Order
1037
         */
1038
        public function setDiscount($discount)
1039 28
        {
1040
            $this->discount = $discount;
1041 28
1042
            return $this;
1043
        }
1044
1045
        /**
1046
         * Get discount.
1047
         *
1048
         * @deprecated 4.0.3 から値引きは課税値引きと 非課税・不課税の値引きの2種に分かれる. 課税値引きについてはgetTaxableDiscountを利用してください.
1049
         * @return string
1050
         */
1051 218
        public function getDiscount()
1052
        {
1053 218
            return $this->discount;
1054
        }
1055 218
1056
        /**
1057
         * Set deliveryFeeTotal.
1058
         *
1059
         * @param string $deliveryFeeTotal
1060
         *
1061
         * @return Order
1062
         */
1063 20
        public function setDeliveryFeeTotal($deliveryFeeTotal)
1064
        {
1065 20
            $this->delivery_fee_total = $deliveryFeeTotal;
1066
1067
            return $this;
1068
        }
1069
1070
        /**
1071
         * Get deliveryFeeTotal.
1072
         *
1073
         * @return string
1074
         */
1075 156
        public function getDeliveryFeeTotal()
1076
        {
1077 156
            return $this->delivery_fee_total;
1078
        }
1079 156
1080
        /**
1081
         * Set charge.
1082
         *
1083
         * @param string $charge
1084
         *
1085
         * @return Order
1086
         */
1087 20
        public function setCharge($charge)
1088
        {
1089 20
            $this->charge = $charge;
1090
1091
            return $this;
1092
        }
1093
1094
        /**
1095
         * Get charge.
1096
         *
1097
         * @return string
1098
         */
1099 207
        public function getCharge()
1100
        {
1101 207
            return $this->charge;
1102
        }
1103 207
1104
        /**
1105
         * Set tax.
1106
         *
1107
         * @param string $tax
1108
         *
1109
         * @return Order
1110
         *
1111 3
         * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
1112
         */
1113 3
        public function setTax($tax)
1114
        {
1115
            $this->tax = $tax;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Order::$tax has been deprecated with message: 明細ごとに集計した税額と差異が発生する場合があるため非推奨

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
1116
1117
            return $this;
1118
        }
1119
1120
        /**
1121
         * Get tax.
1122
         *
1123 207
         * @return string
1124
         *
1125 207
         * @deprecated 明細ごとに集計した税額と差異が発生する場合があるため非推奨
1126
         */
1127 207
        public function getTax()
1128
        {
1129
            return $this->tax;
0 ignored issues
show
Deprecated Code introduced by
The property Eccube\Entity\Order::$tax has been deprecated with message: 明細ごとに集計した税額と差異が発生する場合があるため非推奨

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
1130
        }
1131
1132
        /**
1133
         * Set total.
1134
         *
1135 2
         * @param string $total
1136
         *
1137 2
         * @return Order
1138
         */
1139
        public function setTotal($total)
1140
        {
1141
            $this->total = $total;
1142
1143
            return $this;
1144
        }
1145
1146
        /**
1147 47
         * Get total.
1148
         *
1149 47
         * @return string
1150
         */
1151 47
        public function getTotal()
1152
        {
1153
            return $this->total;
1154
        }
1155
1156
        /**
1157
         * Set paymentTotal.
1158
         *
1159 33
         * @param string $paymentTotal
1160
         *
1161 33
         * @return Order
1162
         */
1163
        public function setPaymentTotal($paymentTotal)
1164
        {
1165
            $this->payment_total = $paymentTotal;
1166
1167
            return $this;
1168
        }
1169
1170
        /**
1171 4
         * Get paymentTotal.
1172
         *
1173 4
         * @return string
1174
         */
1175 4
        public function getPaymentTotal()
1176
        {
1177
            return $this->payment_total;
1178
        }
1179
1180
        /**
1181
         * Set paymentMethod.
1182
         *
1183 15
         * @param string|null $paymentMethod
1184
         *
1185 15
         * @return Order
1186
         */
1187
        public function setPaymentMethod($paymentMethod = null)
1188
        {
1189
            $this->payment_method = $paymentMethod;
1190
1191
            return $this;
1192
        }
1193
1194
        /**
1195
         * Get paymentMethod.
1196
         *
1197
         * @return string|null
1198
         */
1199
        public function getPaymentMethod()
1200
        {
1201
            return $this->payment_method;
1202
        }
1203
1204
        /**
1205 207
         * Set note.
1206
         *
1207 207
         * @param string|null $note
1208
         *
1209 207
         * @return Order
1210
         */
1211
        public function setNote($note = null)
1212
        {
1213
            $this->note = $note;
1214
1215 1
            return $this;
1216
        }
1217 1
1218
        /**
1219
         * Get note.
1220
         *
1221
         * @return string|null
1222
         */
1223
        public function getNote()
1224
        {
1225
            return $this->note;
1226
        }
1227
1228
        /**
1229
         * Set createDate.
1230
         *
1231
         * @param \DateTime $createDate
1232
         *
1233
         * @return Order
1234
         */
1235
        public function setCreateDate($createDate)
1236
        {
1237
            $this->create_date = $createDate;
1238
1239
            return $this;
1240
        }
1241
1242
        /**
1243
         * Get createDate.
1244
         *
1245
         * @return \DateTime
1246
         */
1247 11
        public function getCreateDate()
1248
        {
1249 11
            return $this->create_date;
1250
        }
1251
1252
        /**
1253
         * Set updateDate.
1254
         *
1255
         * @param \DateTime $updateDate
1256
         *
1257
         * @return Order
1258
         */
1259
        public function setUpdateDate($updateDate)
1260
        {
1261
            $this->update_date = $updateDate;
1262
1263
            return $this;
1264
        }
1265
1266
        /**
1267
         * Get updateDate.
1268
         *
1269
         * @return \DateTime
1270
         */
1271
        public function getUpdateDate()
1272
        {
1273
            return $this->update_date;
1274
        }
1275
1276
        /**
1277
         * Set orderDate.
1278
         *
1279
         * @param \DateTime|null $orderDate
1280
         *
1281 36
         * @return Order
1282
         */
1283 36
        public function setOrderDate($orderDate = null)
1284
        {
1285 36
            $this->order_date = $orderDate;
1286
1287
            return $this;
1288
        }
1289
1290
        /**
1291
         * Get orderDate.
1292
         *
1293
         * @return \DateTime|null
1294
         */
1295 282
        public function getOrderDate()
1296
        {
1297 282
            return $this->order_date;
1298
        }
1299 282
1300
        /**
1301
         * Set paymentDate.
1302
         *
1303
         * @param \DateTime|null $paymentDate
1304
         *
1305
         * @return Order
1306
         */
1307
        public function setPaymentDate($paymentDate = null)
1308
        {
1309 28
            $this->payment_date = $paymentDate;
1310
1311 28
            return $this;
1312
        }
1313
1314
        /**
1315
         * Get paymentDate.
1316
         *
1317
         * @return \DateTime|null
1318
         */
1319 284
        public function getPaymentDate()
1320
        {
1321 284
            return $this->payment_date;
1322
        }
1323
1324
        /**
1325
         * Get currencyCode.
1326
         *
1327
         * @return string
1328
         */
1329 273
        public function getCurrencyCode()
1330
        {
1331 273
            return $this->currency_code;
1332
        }
1333
1334
        /**
1335
         * Set currencyCode.
1336
         *
1337
         * @param string|null $currencyCode
1338
         *
1339
         * @return $this
1340
         */
1341 218
        public function setCurrencyCode($currencyCode = null)
1342
        {
1343 218
            $this->currency_code = $currencyCode;
1344
1345 218
            return $this;
1346
        }
1347
1348
        /**
1349
         * @return null|string
1350
         */
1351
        public function getCompleteMessage()
1352
        {
1353
            return $this->complete_message;
1354
        }
1355 25
1356
        /**
1357 25
         * @param null|string $complete_message
1358
         *
1359
         * @return $this
1360
         */
1361
        public function setCompleteMessage($complete_message = null)
1362
        {
1363
            $this->complete_message = $complete_message;
1364
1365 115
            return $this;
1366
        }
1367 115
1368 115
        /**
1369
         * @param null|string $complete_message
1370 115
         *
1371
         * @return $this
1372
         */
1373
        public function appendCompleteMessage($complete_message = null)
1374
        {
1375
            $this->complete_message .= $complete_message;
1376
1377
            return $this;
1378
        }
1379
1380
        /**
1381
         * @return null|string
1382
         */
1383
        public function getCompleteMailMessage()
1384
        {
1385
            return $this->complete_mail_message;
1386
        }
1387
1388
        /**
1389
         * @param null|string $complete_mail_message
1390
         *
1391
         * @return
1392
         */
1393
        public function setCompleteMailMessage($complete_mail_message = null)
1394
        {
1395
            $this->complete_mail_message = $complete_mail_message;
1396
1397
            return $this;
1398
        }
1399
1400
        /**
1401
         * @param null|string $complete_mail_message
1402
         *
1403
         * @return
1404 1
         */
1405
        public function appendCompleteMailMessage($complete_mail_message = null)
1406 1
        {
1407
            $this->complete_mail_message .= $complete_mail_message;
1408
1409
            return $this;
1410
        }
1411
1412
        /**
1413
         * 商品の受注明細を取得
1414
         *
1415
         * @return OrderItem[]
1416 246
         */
1417
        public function getProductOrderItems()
1418 246
        {
1419
            $sio = new OrderItemCollection($this->OrderItems->toArray());
1420 246
1421
            return array_values($sio->getProductClasses()->toArray());
1422
        }
1423
1424
        /**
1425
         * Add orderItem.
1426
         *
1427
         * @param \Eccube\Entity\OrderItem $OrderItem
1428 273
         *
1429
         * @return Order
1430 273
         */
1431
        public function addOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1432
        {
1433
            $this->OrderItems[] = $OrderItem;
1434
1435
            return $this;
1436
        }
1437
1438
        /**
1439
         * Remove orderItem.
1440
         *
1441
         * @param \Eccube\Entity\OrderItem $OrderItem
1442
         *
1443
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1444
         */
1445
        public function removeOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1446
        {
1447
            return $this->OrderItems->removeElement($OrderItem);
1448
        }
1449
1450
        /**
1451
         * Get orderItems.
1452
         *
1453
         * @return \Doctrine\Common\Collections\Collection|OrderItem[]
1454
         */
1455
        public function getOrderItems()
1456
        {
1457
            return $this->OrderItems;
1458
        }
1459
1460
        /**
1461
         * Sorted to getOrderItems()
1462
         *
1463
         * @return ItemCollection
1464 167
         */
1465
        public function getItems()
1466 167
        {
1467
            return (new ItemCollection($this->getOrderItems()))->sort();
1468 167
        }
1469
1470
        /**
1471
         * Add shipping.
1472
         *
1473
         * @param \Eccube\Entity\Shipping $Shipping
1474
         *
1475
         * @return Order
1476 73
         */
1477
        public function addShipping(\Eccube\Entity\Shipping $Shipping)
1478 73
        {
1479
            $this->Shippings[] = $Shipping;
1480
1481
            return $this;
1482
        }
1483
1484
        /**
1485
         * Remove shipping.
1486
         *
1487
         * @param \Eccube\Entity\Shipping $Shipping
1488 6
         *
1489
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1490 6
         */
1491
        public function removeShipping(\Eccube\Entity\Shipping $Shipping)
1492 6
        {
1493
            return $this->Shippings->removeElement($Shipping);
1494
        }
1495
1496
        /**
1497
         * Get shippings.
1498
         *
1499
         * @return \Doctrine\Common\Collections\Collection|\Eccube\Entity\Shipping[]
1500 3
         */
1501
        public function getShippings()
1502 3
        {
1503
            $criteria = Criteria::create()
1504
            ->orderBy(['name01' => Criteria::ASC, 'name02' => Criteria::ASC, 'id' => Criteria::ASC]);
1505
1506
            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...
1507
        }
1508
1509
        /**
1510
         * Add mailHistory.
1511
         *
1512 5
         * @param \Eccube\Entity\MailHistory $mailHistory
1513
         *
1514 5
         * @return Order
1515
         */
1516 5
        public function addMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1517
        {
1518
            $this->MailHistories[] = $mailHistory;
1519
1520
            return $this;
1521
        }
1522
1523
        /**
1524 3
         * Remove mailHistory.
1525
         *
1526 3
         * @param \Eccube\Entity\MailHistory $mailHistory
1527
         *
1528
         * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1529
         */
1530
        public function removeMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1531
        {
1532
            return $this->MailHistories->removeElement($mailHistory);
1533
        }
1534
1535
        /**
1536 218
         * Get mailHistories.
1537
         *
1538 218
         * @return \Doctrine\Common\Collections\Collection
1539
         */
1540 218
        public function getMailHistories()
1541
        {
1542
            return $this->MailHistories;
1543
        }
1544
1545
        /**
1546
         * Set customer.
1547
         *
1548 218
         * @param \Eccube\Entity\Customer|null $customer
1549
         *
1550 218
         * @return Order
1551
         */
1552
        public function setCustomer(\Eccube\Entity\Customer $customer = null)
1553
        {
1554
            $this->Customer = $customer;
1555
1556
            return $this;
1557
        }
1558
1559
        /**
1560 51
         * Get customer.
1561
         *
1562 51
         * @return \Eccube\Entity\Customer|null
1563
         */
1564 51
        public function getCustomer()
1565
        {
1566
            return $this->Customer;
1567
        }
1568
1569
        /**
1570
         * Set country.
1571
         *
1572 2
         * @param \Eccube\Entity\Master\Country|null $country
1573
         *
1574 2
         * @return Order
1575
         */
1576
        public function setCountry(\Eccube\Entity\Master\Country $country = null)
1577
        {
1578
            $this->Country = $country;
1579
1580
            return $this;
1581
        }
1582
1583
        /**
1584
         * Get country.
1585
         *
1586
         * @return \Eccube\Entity\Master\Country|null
1587
         */
1588
        public function getCountry()
1589
        {
1590
            return $this->Country;
1591
        }
1592
1593
        /**
1594
         * Set pref.
1595
         *
1596
         * @param \Eccube\Entity\Master\Pref|null $pref
1597
         *
1598
         * @return Order
1599
         */
1600
        public function setPref(\Eccube\Entity\Master\Pref $pref = null)
1601
        {
1602
            $this->Pref = $pref;
1603
1604
            return $this;
1605
        }
1606
1607
        /**
1608 356
         * Get pref.
1609
         *
1610 356
         * @return \Eccube\Entity\Master\Pref|null
1611
         */
1612 356
        public function getPref()
1613
        {
1614
            return $this->Pref;
1615
        }
1616
1617
        /**
1618
         * Set sex.
1619
         *
1620 237
         * @param \Eccube\Entity\Master\Sex|null $sex
1621
         *
1622 237
         * @return Order
1623
         */
1624
        public function setSex(\Eccube\Entity\Master\Sex $sex = null)
1625
        {
1626
            $this->Sex = $sex;
1627
1628 72
            return $this;
1629
        }
1630 72
1631
        /**
1632
         * Get sex.
1633 1
         *
1634
         * @return \Eccube\Entity\Master\Sex|null
1635 1
         */
1636 1
        public function getSex()
1637 1
        {
1638
            return $this->Sex;
1639
        }
1640 1
1641
        /**
1642
         * Set job.
1643
         *
1644
         * @param \Eccube\Entity\Master\Job|null $job
1645
         *
1646
         * @return Order
1647
         */
1648
        public function setJob(\Eccube\Entity\Master\Job $job = null)
1649
        {
1650
            $this->Job = $job;
1651
1652
            return $this;
1653
        }
1654
1655
        /**
1656
         * Get job.
1657
         *
1658
         * @return \Eccube\Entity\Master\Job|null
1659
         */
1660
        public function getJob()
1661
        {
1662
            return $this->Job;
1663
        }
1664
1665
        /**
1666
         * Set payment.
1667
         *
1668
         * @param \Eccube\Entity\Payment|null $payment
1669
         *
1670
         * @return Order
1671
         */
1672
        public function setPayment(\Eccube\Entity\Payment $payment = null)
1673
        {
1674
            $this->Payment = $payment;
1675
1676
            return $this;
1677
        }
1678
1679
        /**
1680
         * Get payment.
1681
         *
1682
         * @return \Eccube\Entity\Payment|null
1683
         */
1684
        public function getPayment()
1685
        {
1686
            return $this->Payment;
1687
        }
1688
1689
        /**
1690
         * Set deviceType.
1691
         *
1692
         * @param \Eccube\Entity\Master\DeviceType|null $deviceType
1693
         *
1694
         * @return Order
1695
         */
1696
        public function setDeviceType(\Eccube\Entity\Master\DeviceType $deviceType = null)
1697
        {
1698
            $this->DeviceType = $deviceType;
1699
1700
            return $this;
1701
        }
1702
1703
        /**
1704
         * Get deviceType.
1705
         *
1706
         * @return \Eccube\Entity\Master\DeviceType|null
1707
         */
1708
        public function getDeviceType()
1709
        {
1710
            return $this->DeviceType;
1711
        }
1712
1713
        /**
1714
         * Set customerOrderStatus.
1715
         *
1716
         * @param \Eccube\Entity\Master\CustomerOrderStatus|null $customerOrderStatus
1717
         *
1718
         * @return Order
1719
         */
1720
        public function setCustomerOrderStatus(\Eccube\Entity\Master\CustomerOrderStatus $customerOrderStatus = null)
1721
        {
1722
            $this->CustomerOrderStatus = $customerOrderStatus;
1723
1724
            return $this;
1725
        }
1726
1727
        /**
1728
         * Get customerOrderStatus.
1729
         *
1730
         * @return \Eccube\Entity\Master\CustomerOrderStatus|null
1731
         */
1732
        public function getCustomerOrderStatus()
1733
        {
1734
            return $this->CustomerOrderStatus;
1735
        }
1736
1737
        /**
1738
         * Set orderStatusColor.
1739
         *
1740
         * @param \Eccube\Entity\Master\OrderStatusColor|null $orderStatusColor
1741
         *
1742
         * @return Order
1743
         */
1744
        public function setOrderStatusColor(\Eccube\Entity\Master\OrderStatusColor $orderStatusColor = null)
1745
        {
1746
            $this->OrderStatusColor = $orderStatusColor;
1747
1748
            return $this;
1749
        }
1750
1751
        /**
1752
         * Get orderStatusColor.
1753
         *
1754
         * @return \Eccube\Entity\Master\OrderStatusColor|null
1755
         */
1756
        public function getOrderStatusColor()
1757
        {
1758
            return $this->OrderStatusColor;
1759
        }
1760
1761
        /**
1762
         * Set orderStatus.
1763
         *
1764
         * @param \Eccube\Entity\Master\OrderStatus|null|object $orderStatus
1765
         *
1766
         * @return Order
1767
         */
1768
        public function setOrderStatus(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
1769
        {
1770
            $this->OrderStatus = $orderStatus;
1771
1772
            return $this;
1773
        }
1774
1775
        /**
1776
         * Get orderStatus.
1777
         *
1778
         * @return \Eccube\Entity\Master\OrderStatus|null
1779
         */
1780
        public function getOrderStatus()
1781
        {
1782
            return $this->OrderStatus;
1783
        }
1784
1785
        /**
1786
         * @param ItemInterface $item
1787
         */
1788
        public function addItem(ItemInterface $item)
1789
        {
1790
            $this->OrderItems->add($item);
1791
        }
1792
1793
        public function getQuantity()
1794
        {
1795
            $quantity = 0;
1796
            foreach ($this->getItems() as $item) {
1797
                $quantity += $item->getQuantity();
1798
            }
1799
1800
            return $quantity;
1801
        }
1802
    }
1803
}
1804