Failed Conditions
Pull Request — experimental/sf (#3236)
by Kentaro
144:19 queued 116:23
created

Order::setPaymentDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
ccs 3
cts 3
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) 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
/**
23
 * Order
24
 *
25
 * @ORM\Table(name="dtb_order", indexes={
26
 *     @ORM\Index(name="dtb_order_pre_order_id_idx", columns={"pre_order_id"}),
27
 *     @ORM\Index(name="dtb_order_email_idx", columns={"email"}),
28
 *     @ORM\Index(name="dtb_order_order_date_idx", columns={"order_date"}),
29
 *     @ORM\Index(name="dtb_order_payment_date_idx", columns={"payment_date"}),
30
 *     @ORM\Index(name="dtb_order_update_date_idx", columns={"update_date"}),
31
 *     @ORM\Index(name="dtb_order_order_no_idx", columns={"order_no"})
32
 *  })
33
 * @ORM\InheritanceType("SINGLE_TABLE")
34
 * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
35
 * @ORM\HasLifecycleCallbacks()
36
 * @ORM\Entity(repositoryClass="Eccube\Repository\OrderRepository")
37
 */
38
class Order extends \Eccube\Entity\AbstractEntity implements PurchaseInterface, ItemHolderInterface
39
{
40
    use NameTrait, PointTrait;
41
42
    /**
43
     * 複数配送かどうかの判定を行う.
44
     *
45
     * @return boolean
46
     */
47 65
    public function isMultiple()
48
    {
49 65
        $Shippings = [];
50
        // クエリビルダ使用時に絞り込まれる場合があるため,
51
        // getShippingsではなくOrderItem経由でShippingを取得する.
52 65
        foreach ($this->getOrderItems() as $OrderItem) {
53 64
            if ($Shipping = $OrderItem->getShipping()) {
54 62
                $id = $Shipping->getId();
55 62
                if (isset($Shippings[$id])) {
56 62
                    continue;
57
                }
58 64
                $Shippings[$id] = $Shipping;
59
            }
60
        }
61
62 65
        return count($Shippings) > 1 ? true : false;
63
    }
64
65
    /**
66
     * 対象となるお届け先情報を取得
67
     *
68
     * @param integer $shippingId
69
     *
70
     * @return \Eccube\Entity\Shipping|null
71
     */
72
    public function findShipping($shippingId)
73
    {
74
        foreach ($this->getShippings() as $Shipping) {
75
            if ($Shipping->getId() == $shippingId) {
76
                return $Shipping;
77
            }
78
        }
79
80
        return null;
81
    }
82
83
    /**
84
     * この注文の保持する販売種別を取得します.
85
     *
86
     * @return \Eccube\Entity\Master\SaleType[] 一意な販売種別の配列
87
     */
88 1
    public function getSaleTypes()
89
    {
90 1
        $saleTypes = [];
91 1
        foreach ($this->getOrderItems() as $OrderItem) {
92
            /* @var $ProductClass \Eccube\Entity\ProductClass */
93 1
            $ProductClass = $OrderItem->getProductClass();
94 1
            if ($ProductClass) {
95 1
                $saleTypes[] = $ProductClass->getSaleType();
96
            }
97
        }
98
99 1
        return array_unique($saleTypes);
100
    }
101
102
    /**
103
     * 同じ規格の商品の個数をまとめた受注明細を取得
104
     *
105
     * @return OrderItem[]
106
     */
107 1
    public function getMergedProductOrderItems()
108
    {
109 1
        $ProductOrderItems = $this->getProductOrderItems();
110 1
        $orderItemArray = [];
111
        /** @var OrderItem $ProductOrderItem */
112 1
        foreach ($ProductOrderItems as $ProductOrderItem) {
113 1
            $productClassId = $ProductOrderItem->getProductClass()->getId();
114 1
            if (array_key_exists($productClassId, $orderItemArray)) {
115
                // 同じ規格の商品がある場合は個数をまとめる
116
                /** @var ItemInterface $OrderItem */
117 1
                $OrderItem = $orderItemArray[$productClassId];
118 1
                $quantity = $OrderItem->getQuantity() + $ProductOrderItem->getQuantity();
119 1
                $OrderItem->setQuantity($quantity);
120
            } else {
121
                // 新規規格の商品は新しく追加する
122 1
                $OrderItem = new OrderItem();
123
                $OrderItem
124 1
                    ->setProduct($ProductOrderItem->getProduct())
125 1
                    ->setProductName($ProductOrderItem->getProductName())
126 1
                    ->setClassCategoryName1($ProductOrderItem->getClassCategoryName1())
127 1
                    ->setClassCategoryName2($ProductOrderItem->getClassCategoryName2())
128 1
                    ->setPrice($ProductOrderItem->getPrice())
129 1
                    ->setTax($ProductOrderItem->getTax())
130 1
                    ->setQuantity($ProductOrderItem->getQuantity());
131 1
                $orderItemArray[$productClassId] = $OrderItem;
132
            }
133
        }
134
135 1
        return array_values($orderItemArray);
136
    }
137
138
    /**
139
     * 合計金額を計算
140
     *
141
     * @return string
142
     *
143
     * @deprecated
144
     */
145 1
    public function getTotalPrice()
146
    {
147 1
        @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...
148
149 1
        return $this->getSubtotal() + $this->getCharge() + $this->getDeliveryFeeTotal() - $this->getDiscount();
150
//        return $this->getSubtotal() + $this->getCharge() - $this->getDiscount();
151
    }
152
153
    /**
154
     * @var integer
155
     *
156
     * @ORM\Column(name="id", type="integer", options={"unsigned":true})
157
     * @ORM\Id
158
     * @ORM\GeneratedValue(strategy="IDENTITY")
159
     */
160
    private $id;
161
162
    /**
163
     * @var string|null
164
     *
165
     * @ORM\Column(name="pre_order_id", type="string", length=255, nullable=true)
166
     */
167
    private $pre_order_id;
168
169
    /**
170
     * @var string|null
171
     *
172
     * @ORM\Column(name="order_no", type="string", length=255, nullable=true)
173
     */
174
    private $order_no;
175
176
    /**
177
     * @var string|null
178
     *
179
     * @ORM\Column(name="message", type="string", length=4000, nullable=true)
180
     */
181
    private $message;
182
183
    /**
184
     * @var string|null
185
     *
186
     * @ORM\Column(name="name01", type="string", length=255, nullable=true)
187
     */
188
    private $name01;
189
190
    /**
191
     * @var string|null
192
     *
193
     * @ORM\Column(name="name02", type="string", length=255, nullable=true)
194
     */
195
    private $name02;
196
197
    /**
198
     * @var string|null
199
     *
200
     * @ORM\Column(name="kana01", type="string", length=255, nullable=true)
201
     */
202
    private $kana01;
203
204
    /**
205
     * @var string|null
206
     *
207
     * @ORM\Column(name="kana02", type="string", length=255, nullable=true)
208
     */
209
    private $kana02;
210
211
    /**
212
     * @var string|null
213
     *
214
     * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
215
     */
216
    private $company_name;
217
218
    /**
219
     * @var string|null
220
     *
221
     * @ORM\Column(name="email", type="string", length=255, nullable=true)
222
     */
223
    private $email;
224
225
    /**
226
     * @var string|null
227
     *
228
     * @ORM\Column(name="phone_number", type="string", length=14, nullable=true)
229
     */
230
    private $phone_number;
231
232
    /**
233
     * @var string|null
234
     *
235
     * @ORM\Column(name="postal_code", type="string", length=8, nullable=true)
236
     */
237
    private $postal_code;
238
239
    /**
240
     * @var string|null
241
     *
242
     * @ORM\Column(name="addr01", type="string", length=255, nullable=true)
243
     */
244
    private $addr01;
245
246
    /**
247
     * @var string|null
248
     *
249
     * @ORM\Column(name="addr02", type="string", length=255, nullable=true)
250
     */
251
    private $addr02;
252
253
    /**
254
     * @var \DateTime|null
255
     *
256
     * @ORM\Column(name="birth", type="datetimetz", nullable=true)
257
     */
258
    private $birth;
259
260
    /**
261
     * @var string
262
     *
263
     * @ORM\Column(name="subtotal", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
264
     */
265
    private $subtotal = 0;
266
267
    /**
268
     * @var string
269
     *
270
     * @ORM\Column(name="discount", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
271
     */
272
    private $discount = 0;
273
274
    /**
275
     * @var string
276
     *
277
     * @ORM\Column(name="delivery_fee_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
278
     */
279
    private $delivery_fee_total = 0;
280
281
    /**
282
     * @var string
283
     *
284
     * @ORM\Column(name="charge", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
285
     */
286
    private $charge = 0;
287
288
    /**
289
     * @var string
290
     *
291
     * @ORM\Column(name="tax", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
292
     */
293
    private $tax = 0;
294
295
    /**
296
     * @var string
297
     *
298
     * @ORM\Column(name="total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
299
     */
300
    private $total = 0;
301
302
    /**
303
     * @var string
304
     *
305
     * @ORM\Column(name="payment_total", type="decimal", precision=12, scale=2, options={"unsigned":true,"default":0})
306
     */
307
    private $payment_total = 0;
308
309
    /**
310
     * @var string|null
311
     *
312
     * @ORM\Column(name="payment_method", type="string", length=255, nullable=true)
313
     */
314
    private $payment_method;
315
316
    /**
317
     * @var string|null
318
     *
319
     * @ORM\Column(name="note", type="string", length=4000, nullable=true)
320
     */
321
    private $note;
322
323
    /**
324
     * @var \DateTime
325
     *
326
     * @ORM\Column(name="create_date", type="datetimetz")
327
     */
328
    private $create_date;
329
330
    /**
331
     * @var \DateTime
332
     *
333
     * @ORM\Column(name="update_date", type="datetimetz")
334
     */
335
    private $update_date;
336
337
    /**
338
     * @var \DateTime|null
339
     *
340
     * @ORM\Column(name="order_date", type="datetimetz", nullable=true)
341
     */
342
    private $order_date;
343
344
    /**
345
     * @var \DateTime|null
346
     *
347
     * @ORM\Column(name="payment_date", type="datetimetz", nullable=true)
348
     */
349
    private $payment_date;
350
351
    /**
352
     * @var string|null
353
     *
354
     * @ORM\Column(name="currency_code", type="string", nullable=true)
355
     */
356
    private $currency_code;
357
358
    /**
359
     * 注文完了画面に表示するメッセージ
360
     *
361
     * プラグインから注文完了時にメッセージを表示したい場合, このフィールドにセットすることで, 注文完了画面で表示されます。
362
     * 複数のプラグインから利用されるため, appendCompleteMesssage()で追加してください.
363
     * 表示する際にHTMLは利用可能です。
364
     *
365
     * @var string|null
366
     *
367
     * @ORM\Column(name="complete_message", type="text", nullable=true)
368
     */
369
    private $complete_message;
370
371
    /**
372
     * 注文完了メールに表示するメッセージ
373
     *
374
     * プラグインから注文完了メールにメッセージを表示したい場合, このフィールドにセットすることで, 注文完了メールで表示されます。
375
     * 複数のプラグインから利用されるため, appendCompleteMailMesssage()で追加してください.
376
     *
377
     * @var string|null
378
     *
379
     * @ORM\Column(name="complete_mail_message", type="text", nullable=true)
380
     */
381
    private $complete_mail_message;
382
383
    /**
384
     * @var \Doctrine\Common\Collections\Collection|OrderItem[]
385
     *
386
     * @ORM\OneToMany(targetEntity="Eccube\Entity\OrderItem", mappedBy="Order", cascade={"persist","remove"})
387
     */
388
    private $OrderItems;
389
390
    /**
391
     * @var \Doctrine\Common\Collections\Collection|Shipping[]
392
     *
393
     * @ORM\OneToMany(targetEntity="Eccube\Entity\Shipping", mappedBy="Order", cascade={"persist","remove"})
394
     */
395
    private $Shippings;
396
397
    /**
398
     * @var \Doctrine\Common\Collections\Collection
399
     *
400
     * @ORM\OneToMany(targetEntity="Eccube\Entity\MailHistory", mappedBy="Order", cascade={"remove"})
401
     * @ORM\OrderBy({
402
     *     "send_date"="DESC"
403
     * })
404
     */
405
    private $MailHistories;
406
407
    /**
408
     * @var \Eccube\Entity\Customer
409
     *
410
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Customer", inversedBy="Orders")
411
     * @ORM\JoinColumns({
412
     *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
413
     * })
414
     */
415
    private $Customer;
416
417
    /**
418
     * @var \Eccube\Entity\Master\Country
419
     *
420
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Country")
421
     * @ORM\JoinColumns({
422
     *   @ORM\JoinColumn(name="country_id", referencedColumnName="id")
423
     * })
424
     */
425
    private $Country;
426
427
    /**
428
     * @var \Eccube\Entity\Master\Pref
429
     *
430
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Pref")
431
     * @ORM\JoinColumns({
432
     *   @ORM\JoinColumn(name="pref_id", referencedColumnName="id")
433
     * })
434
     */
435
    private $Pref;
436
437
    /**
438
     * @var \Eccube\Entity\Master\Sex
439
     *
440
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Sex")
441
     * @ORM\JoinColumns({
442
     *   @ORM\JoinColumn(name="sex_id", referencedColumnName="id")
443
     * })
444
     */
445
    private $Sex;
446
447
    /**
448
     * @var \Eccube\Entity\Master\Job
449
     *
450
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\Job")
451
     * @ORM\JoinColumns({
452
     *   @ORM\JoinColumn(name="job_id", referencedColumnName="id")
453
     * })
454
     */
455
    private $Job;
456
457
    /**
458
     * @var \Eccube\Entity\Payment
459
     *
460
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Payment")
461
     * @ORM\JoinColumns({
462
     *   @ORM\JoinColumn(name="payment_id", referencedColumnName="id")
463
     * })
464
     */
465
    private $Payment;
466
467
    /**
468
     * @var \Eccube\Entity\Master\DeviceType
469
     *
470
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\DeviceType")
471
     * @ORM\JoinColumns({
472
     *   @ORM\JoinColumn(name="device_type_id", referencedColumnName="id")
473
     * })
474
     */
475
    private $DeviceType;
476
477
    /**
478
     * @var \Eccube\Entity\Master\CustomerOrderStatus
479
     *
480
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\CustomerOrderStatus")
481
     * @ORM\JoinColumns({
482
     *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
483
     * })
484
     */
485
    private $CustomerOrderStatus;
486
487
    /**
488
     * @var \Eccube\Entity\Master\OrderStatus
489
     *
490
     * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\OrderStatus")
491
     * @ORM\JoinColumns({
492
     *   @ORM\JoinColumn(name="order_status_id", referencedColumnName="id")
493
     * })
494
     */
495
    private $OrderStatus;
496
497
    /**
498
     * Constructor
499
     */
500 354
    public function __construct(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
501
    {
502 354
        $this->setDiscount(0)
503 354
            ->setSubtotal(0)
504 354
            ->setTotal(0)
505 354
            ->setPaymentTotal(0)
506 354
            ->setCharge(0)
507 354
            ->setTax(0)
508 354
            ->setDeliveryFeeTotal(0)
509 354
            ->setOrderStatus($orderStatus)
510
        ;
511
512 354
        $this->OrderItems = new \Doctrine\Common\Collections\ArrayCollection();
513 354
        $this->Shippings = new \Doctrine\Common\Collections\ArrayCollection();
514 354
        $this->MailHistories = new \Doctrine\Common\Collections\ArrayCollection();
515
    }
516
517
    /**
518
     * Clone
519
     */
520 7
    public function __clone()
521
    {
522 7
        $OrderItems = new ArrayCollection();
523 7
        foreach ($this->OrderItems as $OrderItem) {
524 4
            $OrderItems->add(clone $OrderItem);
525
        }
526 7
        $this->OrderItems = $OrderItems;
527
    }
528
529
    /**
530
     * Get id.
531
     *
532
     * @return int
533
     */
534 123
    public function getId()
535
    {
536 123
        return $this->id;
537
    }
538
539
    /**
540
     * Set preOrderId.
541
     *
542
     * @param string|null $preOrderId
543
     *
544
     * @return Order
545
     */
546 203
    public function setPreOrderId($preOrderId = null)
547
    {
548 203
        $this->pre_order_id = $preOrderId;
549
550 203
        return $this;
551
    }
552
553
    /**
554
     * Get preOrderId.
555
     *
556
     * @return string|null
557
     */
558 53
    public function getPreOrderId()
559
    {
560 53
        return $this->pre_order_id;
561
    }
562
563
    /**
564
     * Set orderNo
565
     *
566
     * @param string|null $orderNo
567
     *
568
     * @return Order
569
     */
570 225
    public function setOrderNo($orderNo = null)
571
    {
572 225
        $this->order_no = $orderNo;
573
574 225
        return $this;
575
    }
576
577
    /**
578
     * Get orderNo
579
     *
580
     * @return string|null
581
     */
582 97
    public function getOrderNo()
583
    {
584 97
        return $this->order_no;
585
    }
586
587
    /**
588
     * Set message.
589
     *
590
     * @param string|null $message
591
     *
592
     * @return Order
593
     */
594 179
    public function setMessage($message = null)
595
    {
596 179
        $this->message = $message;
597
598 179
        return $this;
599
    }
600
601
    /**
602
     * Get message.
603
     *
604
     * @return string|null
605
     */
606 81
    public function getMessage()
607
    {
608 81
        return $this->message;
609
    }
610
611
    /**
612
     * Set name01.
613
     *
614
     * @param string|null $name01
615
     *
616
     * @return Order
617
     */
618 18
    public function setName01($name01 = null)
619
    {
620 18
        $this->name01 = $name01;
621
622 18
        return $this;
623
    }
624
625
    /**
626
     * Get name01.
627
     *
628
     * @return string|null
629
     */
630 80
    public function getName01()
631
    {
632 80
        return $this->name01;
633
    }
634
635
    /**
636
     * Set name02.
637
     *
638
     * @param string|null $name02
639
     *
640
     * @return Order
641
     */
642 18
    public function setName02($name02 = null)
643
    {
644 18
        $this->name02 = $name02;
645
646 18
        return $this;
647
    }
648
649
    /**
650
     * Get name02.
651
     *
652
     * @return string|null
653
     */
654 80
    public function getName02()
655
    {
656 80
        return $this->name02;
657
    }
658
659
    /**
660
     * Set kana01.
661
     *
662
     * @param string|null $kana01
663
     *
664
     * @return Order
665
     */
666 19
    public function setKana01($kana01 = null)
667
    {
668 19
        $this->kana01 = $kana01;
669
670 19
        return $this;
671
    }
672
673
    /**
674
     * Get kana01.
675
     *
676
     * @return string|null
677
     */
678 70
    public function getKana01()
679
    {
680 70
        return $this->kana01;
681
    }
682
683
    /**
684
     * Set kana02.
685
     *
686
     * @param string|null $kana02
687
     *
688
     * @return Order
689
     */
690 19
    public function setKana02($kana02 = null)
691
    {
692 19
        $this->kana02 = $kana02;
693
694 19
        return $this;
695
    }
696
697
    /**
698
     * Get kana02.
699
     *
700
     * @return string|null
701
     */
702 70
    public function getKana02()
703
    {
704 70
        return $this->kana02;
705
    }
706
707
    /**
708
     * Set companyName.
709
     *
710
     * @param string|null $companyName
711
     *
712
     * @return Order
713
     */
714 16
    public function setCompanyName($companyName = null)
715
    {
716 16
        $this->company_name = $companyName;
717
718 16
        return $this;
719
    }
720
721
    /**
722
     * Get companyName.
723
     *
724
     * @return string|null
725
     */
726 71
    public function getCompanyName()
727
    {
728 71
        return $this->company_name;
729
    }
730
731
    /**
732
     * Set email.
733
     *
734
     * @param string|null $email
735
     *
736
     * @return Order
737
     */
738 16
    public function setEmail($email = null)
739
    {
740 16
        $this->email = $email;
741
742 16
        return $this;
743
    }
744
745
    /**
746
     * Get email.
747
     *
748
     * @return string|null
749
     */
750 74
    public function getEmail()
751
    {
752 74
        return $this->email;
753
    }
754
755
    /**
756
     * Set phone_number.
757
     *
758
     * @param string|null $phone_number
759
     *
760
     * @return Order
761
     */
762 17
    public function setPhoneNumber($phone_number = null)
763
    {
764 17
        $this->phone_number = $phone_number;
765
766 17
        return $this;
767
    }
768
769
    /**
770
     * Get phone_number.
771
     *
772
     * @return string|null
773
     */
774 70
    public function getPhoneNumber()
775
    {
776 70
        return $this->phone_number;
777
    }
778
779
    /**
780
     * Set postal_code.
781
     *
782
     * @param string|null $postal_code
783
     *
784
     * @return Order
785
     */
786 16
    public function setPostalCode($postal_code = null)
787
    {
788 16
        $this->postal_code = $postal_code;
789
790 16
        return $this;
791
    }
792
793
    /**
794
     * Get postal_code.
795
     *
796
     * @return string|null
797
     */
798 70
    public function getPostalCode()
799
    {
800 70
        return $this->postal_code;
801
    }
802
803
    /**
804
     * Set addr01.
805
     *
806
     * @param string|null $addr01
807
     *
808
     * @return Order
809
     */
810 16
    public function setAddr01($addr01 = null)
811
    {
812 16
        $this->addr01 = $addr01;
813
814 16
        return $this;
815
    }
816
817
    /**
818
     * Get addr01.
819
     *
820
     * @return string|null
821
     */
822 73
    public function getAddr01()
823
    {
824 73
        return $this->addr01;
825
    }
826
827
    /**
828
     * Set addr02.
829
     *
830
     * @param string|null $addr02
831
     *
832
     * @return Order
833
     */
834 16
    public function setAddr02($addr02 = null)
835
    {
836 16
        $this->addr02 = $addr02;
837
838 16
        return $this;
839
    }
840
841
    /**
842
     * Get addr02.
843
     *
844
     * @return string|null
845
     */
846 73
    public function getAddr02()
847
    {
848 73
        return $this->addr02;
849
    }
850
851
    /**
852
     * Set birth.
853
     *
854
     * @param \DateTime|null $birth
855
     *
856
     * @return Order
857
     */
858 5
    public function setBirth($birth = null)
859
    {
860 5
        $this->birth = $birth;
861
862 5
        return $this;
863
    }
864
865
    /**
866
     * Get birth.
867
     *
868
     * @return \DateTime|null
869
     */
870 3
    public function getBirth()
871
    {
872 3
        return $this->birth;
873
    }
874
875
    /**
876
     * Set subtotal.
877
     *
878
     * @param string $subtotal
879
     *
880
     * @return Order
881
     */
882 354
    public function setSubtotal($subtotal)
883
    {
884 354
        $this->subtotal = $subtotal;
885
886 354
        return $this;
887
    }
888
889
    /**
890
     * Get subtotal.
891
     *
892
     * @return string
893
     */
894 60
    public function getSubtotal()
895
    {
896 60
        return $this->subtotal;
897
    }
898
899
    /**
900
     * Set discount.
901
     *
902
     * @param string $discount
903
     *
904
     * @return Order
905
     */
906 354
    public function setDiscount($discount)
907
    {
908 354
        $this->discount = $discount;
909
910 354
        return $this;
911
    }
912
913
    /**
914
     * Get discount.
915
     *
916
     * @return string
917
     */
918 210
    public function getDiscount()
919
    {
920 210
        return $this->discount;
921
    }
922
923
    /**
924
     * Set deliveryFeeTotal.
925
     *
926
     * @param string $deliveryFeeTotal
927
     *
928
     * @return Order
929
     */
930 354
    public function setDeliveryFeeTotal($deliveryFeeTotal)
931
    {
932 354
        $this->delivery_fee_total = $deliveryFeeTotal;
933
934 354
        return $this;
935
    }
936
937
    /**
938
     * Get deliveryFeeTotal.
939
     *
940
     * @return string
941
     */
942 75
    public function getDeliveryFeeTotal()
943
    {
944 75
        return $this->delivery_fee_total;
945
    }
946
947
    /**
948
     * Set charge.
949
     *
950
     * @param string $charge
951
     *
952
     * @return Order
953
     */
954 354
    public function setCharge($charge)
955
    {
956 354
        $this->charge = $charge;
957
958 354
        return $this;
959
    }
960
961
    /**
962
     * Get charge.
963
     *
964
     * @return string
965
     */
966 210
    public function getCharge()
967
    {
968 210
        return $this->charge;
969
    }
970
971
    /**
972
     * Set tax.
973
     *
974
     * @param string $tax
975
     *
976
     * @return Order
977
     */
978 354
    public function setTax($tax)
979
    {
980 354
        $this->tax = $tax;
981
982 354
        return $this;
983
    }
984
985
    /**
986
     * Get tax.
987
     *
988
     * @return string
989
     */
990 16
    public function getTax()
991
    {
992 16
        return $this->tax;
993
    }
994
995
    /**
996
     * Set total.
997
     *
998
     * @param string $total
999
     *
1000
     * @return Order
1001
     */
1002 354
    public function setTotal($total)
1003
    {
1004 354
        $this->total = $total;
1005
1006 354
        return $this;
1007
    }
1008
1009
    /**
1010
     * Get total.
1011
     *
1012
     * @return string
1013
     */
1014 235
    public function getTotal()
1015
    {
1016 235
        return $this->total;
1017
    }
1018
1019
    /**
1020
     * Set paymentTotal.
1021
     *
1022
     * @param string $paymentTotal
1023
     *
1024
     * @return Order
1025
     */
1026 354
    public function setPaymentTotal($paymentTotal)
1027
    {
1028 354
        $this->payment_total = $paymentTotal;
1029
1030 354
        return $this;
1031
    }
1032
1033
    /**
1034
     * Get paymentTotal.
1035
     *
1036
     * @return string
1037
     */
1038 28
    public function getPaymentTotal()
1039
    {
1040 28
        return $this->payment_total;
1041
    }
1042
1043
    /**
1044
     * Set paymentMethod.
1045
     *
1046
     * @param string|null $paymentMethod
1047
     *
1048
     * @return Order
1049
     */
1050 216
    public function setPaymentMethod($paymentMethod = null)
1051
    {
1052 216
        $this->payment_method = $paymentMethod;
1053
1054 216
        return $this;
1055
    }
1056
1057
    /**
1058
     * Get paymentMethod.
1059
     *
1060
     * @return string|null
1061
     */
1062 20
    public function getPaymentMethod()
1063
    {
1064 20
        return $this->payment_method;
1065
    }
1066
1067
    /**
1068
     * Set note.
1069
     *
1070
     * @param string|null $note
1071
     *
1072
     * @return Order
1073
     */
1074 154
    public function setNote($note = null)
1075
    {
1076 154
        $this->note = $note;
1077
1078 154
        return $this;
1079
    }
1080
1081
    /**
1082
     * Get note.
1083
     *
1084
     * @return string|null
1085
     */
1086 20
    public function getNote()
1087
    {
1088 20
        return $this->note;
1089
    }
1090
1091
    /**
1092
     * Set createDate.
1093
     *
1094
     * @param \DateTime $createDate
1095
     *
1096
     * @return Order
1097
     */
1098 205
    public function setCreateDate($createDate)
1099
    {
1100 205
        $this->create_date = $createDate;
1101
1102 205
        return $this;
1103
    }
1104
1105
    /**
1106
     * Get createDate.
1107
     *
1108
     * @return \DateTime
1109
     */
1110 3
    public function getCreateDate()
1111
    {
1112 3
        return $this->create_date;
1113
    }
1114
1115
    /**
1116
     * Set updateDate.
1117
     *
1118
     * @param \DateTime $updateDate
1119
     *
1120
     * @return Order
1121
     */
1122 205
    public function setUpdateDate($updateDate)
1123
    {
1124 205
        $this->update_date = $updateDate;
1125
1126 205
        return $this;
1127
    }
1128
1129
    /**
1130
     * Get updateDate.
1131
     *
1132
     * @return \DateTime
1133
     */
1134 2
    public function getUpdateDate()
1135
    {
1136 2
        return $this->update_date;
1137
    }
1138
1139
    /**
1140
     * Set orderDate.
1141
     *
1142
     * @param \DateTime|null $orderDate
1143
     *
1144
     * @return Order
1145
     */
1146 47
    public function setOrderDate($orderDate = null)
1147
    {
1148 47
        $this->order_date = $orderDate;
1149
1150 47
        return $this;
1151
    }
1152
1153
    /**
1154
     * Get orderDate.
1155
     *
1156
     * @return \DateTime|null
1157
     */
1158 33
    public function getOrderDate()
1159
    {
1160 33
        return $this->order_date;
1161
    }
1162
1163
    /**
1164
     * Set paymentDate.
1165
     *
1166
     * @param \DateTime|null $paymentDate
1167
     *
1168
     * @return Order
1169
     */
1170 4
    public function setPaymentDate($paymentDate = null)
1171
    {
1172 4
        $this->payment_date = $paymentDate;
1173
1174 4
        return $this;
1175
    }
1176
1177
    /**
1178
     * Get paymentDate.
1179
     *
1180
     * @return \DateTime|null
1181
     */
1182 15
    public function getPaymentDate()
1183
    {
1184 15
        return $this->payment_date;
1185
    }
1186
1187
    /**
1188
     * Get currencyCode.
1189
     *
1190
     * @return string
1191
     */
1192
    public function getCurrencyCode()
1193
    {
1194
        return $this->currency_code;
1195
    }
1196
1197
    /**
1198
     * Set currencyCode.
1199
     *
1200
     * @param string|null $currencyCode
1201
     *
1202
     * @return $this
1203
     */
1204 205
    public function setCurrencyCode($currencyCode = null)
1205
    {
1206 205
        $this->currency_code = $currencyCode;
1207
1208 205
        return $this;
1209
    }
1210
1211
    /**
1212
     * @return null|string
1213
     */
1214 1
    public function getCompleteMessage()
1215
    {
1216 1
        return $this->complete_message;
1217
    }
1218
1219
    /**
1220
     * @param null|string $complete_message
1221
     *
1222
     * @return $this
1223
     */
1224
    public function setCompleteMessage($complete_message = null)
1225
    {
1226
        $this->complete_message = $complete_message;
1227
1228
        return $this;
1229
    }
1230
1231
    /**
1232
     * @param null|string $complete_message
1233
     *
1234
     * @return $this
1235
     */
1236
    public function appendCompleteMessage($complete_message = null)
1237
    {
1238
        $this->complete_message .= $complete_message;
1239
1240
        return $this;
1241
    }
1242
1243
    /**
1244
     * @return null|string
1245
     */
1246 11
    public function getCompleteMailMessage()
1247
    {
1248 11
        return $this->complete_mail_message;
1249
    }
1250
1251
    /**
1252
     * @param null|string $complete_mail_message
1253
     *
1254
     * @return
1255
     */
1256
    public function setCompleteMailMessage($complete_mail_message = null)
1257
    {
1258
        $this->complete_mail_message = $complete_mail_message;
1259
1260
        return $this;
1261
    }
1262
1263
    /**
1264
     * @param null|string $complete_mail_message
1265
     *
1266
     * @return
1267
     */
1268
    public function appendCompleteMailMessage($complete_mail_message = null)
1269
    {
1270
        $this->complete_mail_message .= $complete_mail_message;
1271
1272
        return $this;
1273
    }
1274
1275
    /**
1276
     * 商品の受注明細を取得
1277
     *
1278
     * @return OrderItem[]
1279
     */
1280 36
    public function getProductOrderItems()
1281
    {
1282 36
        $sio = new OrderItemCollection($this->OrderItems->toArray());
1283
1284 36
        return array_values($sio->getProductClasses()->toArray());
1285
    }
1286
1287
    /**
1288
     * Add orderItem.
1289
     *
1290
     * @param \Eccube\Entity\OrderItem $OrderItem
1291
     *
1292
     * @return Order
1293
     */
1294 280
    public function addOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1295
    {
1296 280
        $this->OrderItems[] = $OrderItem;
1297
1298 280
        return $this;
1299
    }
1300
1301
    /**
1302
     * Remove orderItem.
1303
     *
1304
     * @param \Eccube\Entity\OrderItem $OrderItem
1305
     *
1306
     * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1307
     */
1308 28
    public function removeOrderItem(\Eccube\Entity\OrderItem $OrderItem)
1309
    {
1310 28
        return $this->OrderItems->removeElement($OrderItem);
1311
    }
1312
1313
    /**
1314
     * Get orderItems.
1315
     *
1316
     * @return \Doctrine\Common\Collections\Collection|OrderItem[]
1317
     */
1318 282
    public function getOrderItems()
1319
    {
1320 282
        return $this->OrderItems;
1321
    }
1322
1323
    /**
1324
     * Sorted to getOrderItems()
1325
     *
1326
     * @return ItemCollection
1327
     */
1328 271
    public function getItems()
1329
    {
1330 271
        return (new ItemCollection($this->getOrderItems()))->sort();
1331
    }
1332
1333
    /**
1334
     * Add shipping.
1335
     *
1336
     * @param \Eccube\Entity\Shipping $Shipping
1337
     *
1338
     * @return Order
1339
     */
1340 216
    public function addShipping(\Eccube\Entity\Shipping $Shipping)
1341
    {
1342 216
        $this->Shippings[] = $Shipping;
1343
1344 216
        return $this;
1345
    }
1346
1347
    /**
1348
     * Remove shipping.
1349
     *
1350
     * @param \Eccube\Entity\Shipping $Shipping
1351
     *
1352
     * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1353
     */
1354 25
    public function removeShipping(\Eccube\Entity\Shipping $Shipping)
1355
    {
1356 25
        return $this->Shippings->removeElement($Shipping);
1357
    }
1358
1359
    /**
1360
     * Get shippings.
1361
     *
1362
     * @return \Doctrine\Common\Collections\Collection|\Eccube\Entity\Shipping[]
1363
     */
1364 114
    public function getShippings()
1365
    {
1366 114
        $criteria = Criteria::create()
1367 114
            ->orderBy(['name01' => Criteria::ASC, 'name02' => Criteria::ASC, 'id' => Criteria::ASC]);
1368
1369 114
        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...
1370
    }
1371
1372
    /**
1373
     * Add mailHistory.
1374
     *
1375
     * @param \Eccube\Entity\MailHistory $mailHistory
1376
     *
1377
     * @return Order
1378
     */
1379
    public function addMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1380
    {
1381
        $this->MailHistories[] = $mailHistory;
1382
1383
        return $this;
1384
    }
1385
1386
    /**
1387
     * Remove mailHistory.
1388
     *
1389
     * @param \Eccube\Entity\MailHistory $mailHistory
1390
     *
1391
     * @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
1392
     */
1393
    public function removeMailHistory(\Eccube\Entity\MailHistory $mailHistory)
1394
    {
1395
        return $this->MailHistories->removeElement($mailHistory);
1396
    }
1397
1398
    /**
1399
     * Get mailHistories.
1400
     *
1401
     * @return \Doctrine\Common\Collections\Collection
1402
     */
1403 1
    public function getMailHistories()
1404
    {
1405 1
        return $this->MailHistories;
1406
    }
1407
1408
    /**
1409
     * Set customer.
1410
     *
1411
     * @param \Eccube\Entity\Customer|null $customer
1412
     *
1413
     * @return Order
1414
     */
1415 244
    public function setCustomer(\Eccube\Entity\Customer $customer = null)
1416
    {
1417 244
        $this->Customer = $customer;
1418
1419 244
        return $this;
1420
    }
1421
1422
    /**
1423
     * Get customer.
1424
     *
1425
     * @return \Eccube\Entity\Customer|null
1426
     */
1427 271
    public function getCustomer()
1428
    {
1429 271
        return $this->Customer;
1430
    }
1431
1432
    /**
1433
     * Set country.
1434
     *
1435
     * @param \Eccube\Entity\Master\Country|null $country
1436
     *
1437
     * @return Order
1438
     */
1439
    public function setCountry(\Eccube\Entity\Master\Country $country = null)
1440
    {
1441
        $this->Country = $country;
1442
1443
        return $this;
1444
    }
1445
1446
    /**
1447
     * Get country.
1448
     *
1449
     * @return \Eccube\Entity\Master\Country|null
1450
     */
1451
    public function getCountry()
1452
    {
1453
        return $this->Country;
1454
    }
1455
1456
    /**
1457
     * Set pref.
1458
     *
1459
     * @param \Eccube\Entity\Master\Pref|null $pref
1460
     *
1461
     * @return Order
1462
     */
1463 165
    public function setPref(\Eccube\Entity\Master\Pref $pref = null)
1464
    {
1465 165
        $this->Pref = $pref;
1466
1467 165
        return $this;
1468
    }
1469
1470
    /**
1471
     * Get pref.
1472
     *
1473
     * @return \Eccube\Entity\Master\Pref|null
1474
     */
1475 73
    public function getPref()
1476
    {
1477 73
        return $this->Pref;
1478
    }
1479
1480
    /**
1481
     * Set sex.
1482
     *
1483
     * @param \Eccube\Entity\Master\Sex|null $sex
1484
     *
1485
     * @return Order
1486
     */
1487 6
    public function setSex(\Eccube\Entity\Master\Sex $sex = null)
1488
    {
1489 6
        $this->Sex = $sex;
1490
1491 6
        return $this;
1492
    }
1493
1494
    /**
1495
     * Get sex.
1496
     *
1497
     * @return \Eccube\Entity\Master\Sex|null
1498
     */
1499 3
    public function getSex()
1500
    {
1501 3
        return $this->Sex;
1502
    }
1503
1504
    /**
1505
     * Set job.
1506
     *
1507
     * @param \Eccube\Entity\Master\Job|null $job
1508
     *
1509
     * @return Order
1510
     */
1511 5
    public function setJob(\Eccube\Entity\Master\Job $job = null)
1512
    {
1513 5
        $this->Job = $job;
1514
1515 5
        return $this;
1516
    }
1517
1518
    /**
1519
     * Get job.
1520
     *
1521
     * @return \Eccube\Entity\Master\Job|null
1522
     */
1523 3
    public function getJob()
1524
    {
1525 3
        return $this->Job;
1526
    }
1527
1528
    /**
1529
     * Set payment.
1530
     *
1531
     * @param \Eccube\Entity\Payment|null $payment
1532
     *
1533
     * @return Order
1534
     */
1535 216
    public function setPayment(\Eccube\Entity\Payment $payment = null)
1536
    {
1537 216
        $this->Payment = $payment;
1538
1539 216
        return $this;
1540
    }
1541
1542
    /**
1543
     * Get payment.
1544
     *
1545
     * @return \Eccube\Entity\Payment|null
1546
     */
1547 216
    public function getPayment()
1548
    {
1549 216
        return $this->Payment;
1550
    }
1551
1552
    /**
1553
     * Set deviceType.
1554
     *
1555
     * @param \Eccube\Entity\Master\DeviceType|null $deviceType
1556
     *
1557
     * @return Order
1558
     */
1559 51
    public function setDeviceType(\Eccube\Entity\Master\DeviceType $deviceType = null)
1560
    {
1561 51
        $this->DeviceType = $deviceType;
1562
1563 51
        return $this;
1564
    }
1565
1566
    /**
1567
     * Get deviceType.
1568
     *
1569
     * @return \Eccube\Entity\Master\DeviceType|null
1570
     */
1571 2
    public function getDeviceType()
1572
    {
1573 2
        return $this->DeviceType;
1574
    }
1575
1576
    /**
1577
     * Set customerOrderStatus.
1578
     *
1579
     * @param \Eccube\Entity\Master\CustomerOrderStatus|null $customerOrderStatus
1580
     *
1581
     * @return Order
1582
     */
1583
    public function setCustomerOrderStatus(\Eccube\Entity\Master\CustomerOrderStatus $customerOrderStatus = null)
1584
    {
1585
        $this->CustomerOrderStatus = $customerOrderStatus;
1586
1587
        return $this;
1588
    }
1589
1590
    /**
1591
     * Get customerOrderStatus.
1592
     *
1593
     * @return \Eccube\Entity\Master\CustomerOrderStatus|null
1594
     */
1595
    public function getCustomerOrderStatus()
1596
    {
1597
        return $this->CustomerOrderStatus;
1598
    }
1599
1600
    /**
1601
     * Set orderStatus.
1602
     *
1603
     * @param \Eccube\Entity\Master\OrderStatus|null $orderStatus
1604
     *
1605
     * @return Order
1606
     */
1607 354
    public function setOrderStatus(\Eccube\Entity\Master\OrderStatus $orderStatus = null)
1608
    {
1609 354
        $this->OrderStatus = $orderStatus;
1610
1611 354
        return $this;
1612
    }
1613
1614
    /**
1615
     * Get orderStatus.
1616
     *
1617
     * @return \Eccube\Entity\Master\OrderStatus|null
1618
     */
1619 235
    public function getOrderStatus()
1620
    {
1621 235
        return $this->OrderStatus;
1622
    }
1623
1624
    /**
1625
     * @param ItemInterface $item
1626
     */
1627 72
    public function addItem(ItemInterface $item)
1628
    {
1629 72
        $this->OrderItems->add($item);
1630
    }
1631
1632 1
    public function getQuantity()
1633
    {
1634 1
        $quantity = 0;
1635 1
        foreach ($this->getItems() as $item) {
1636 1
            $quantity += $item->getQuantity();
1637
        }
1638
1639 1
        return $quantity;
1640
    }
1641
}
1642