Failed Conditions
Pull Request — 4.0 (#3791)
by Ryo
07:41
created

ProductClass::setPrice02()   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\ORM\Mapping as ORM;
17
18 1
if (!class_exists('\Eccube\Entity\ProductClass')) {
19
    /**
20
     * ProductClass
21
     *
22
     * @ORM\Table(name="dtb_product_class", indexes={@ORM\Index(name="dtb_product_class_price02_idx", columns={"price02"}), @ORM\Index(name="dtb_product_class_stock_stock_unlimited_idx", columns={"stock", "stock_unlimited"})})
23
     * @ORM\InheritanceType("SINGLE_TABLE")
24
     * @ORM\DiscriminatorColumn(name="discriminator_type", type="string", length=255)
25
     * @ORM\HasLifecycleCallbacks()
26
     * @ORM\Entity(repositoryClass="Eccube\Repository\ProductClassRepository")
27
     */
28
    class ProductClass extends \Eccube\Entity\AbstractEntity
29
    {
30
        private $price01_inc_tax = null;
31
        private $price02_inc_tax = null;
32
        private $tax_rate = false;
33
34
        /**
35
         * 商品規格名を含めた商品名を返す.
36
         *
37
         * @return string
38
         */
39
        public function formattedProductName()
40
        {
41
            $productName = $this->getProduct()->getName();
42
            if ($this->hasClassCategory1()) {
43
                $productName .= ' - '.$this->getClassCategory1()->getName();
44
            }
45
            if ($this->hasClassCategory2()) {
46
                $productName .= ' - '.$this->getClassCategory2()->getName();
47
            }
48
49
            return $productName;
50
        }
51
52
        /**
53
         * Is Enable
54
         *
55
         * @return bool
56
         */
57 80
        public function isEnable()
58
        {
59 80
            return $this->getProduct()->isEnable();
60
        }
61
62
        /**
63
         * Set price01 IncTax
64
         *
65
         * @param  string       $price01_inc_tax
66
         *
67
         * @return ProductClass
68
         */
69 463
        public function setPrice01IncTax($price01_inc_tax)
70
        {
71 463
            $this->price01_inc_tax = $price01_inc_tax;
72
73 463
            return $this;
74
        }
75
76
        /**
77
         * Get price01 IncTax
78
         *
79
         * @return string
80
         */
81 8
        public function getPrice01IncTax()
82
        {
83 8
            return $this->price01_inc_tax;
84
        }
85
86
        /**
87
         * Set price02 IncTax
88
         *
89
         *
90
         * @return ProductClass
91
         */
92 463
        public function setPrice02IncTax($price02_inc_tax)
93
        {
94 463
            $this->price02_inc_tax = $price02_inc_tax;
95
96 463
            return $this;
97
        }
98
99
        /**
100
         * Get price02 IncTax
101
         *
102
         * @return string
103
         */
104 102
        public function getPrice02IncTax()
105
        {
106 102
            return $this->price02_inc_tax;
107
        }
108
109
        /**
110
         * Get StockFind
111
         *
112
         * @return bool
113
         */
114 49
        public function getStockFind()
115
        {
116 49
            if ($this->getStock() > 0 || $this->isStockUnlimited()) {
117 49
                return true;
118
            } else {
119 3
                return false;
120
            }
121
        }
122
123
        /**
124
         * Set tax_rate
125
         *
126
         * @param  string $tax_rate
127
         *
128
         * @return ProductClass
129
         */
130 41
        public function setTaxRate($tax_rate)
131
        {
132 41
            $this->tax_rate = $tax_rate;
0 ignored issues
show
Documentation Bug introduced by
The property $tax_rate was declared of type boolean, but $tax_rate is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
133
134 41
            return $this;
135
        }
136
137
        /**
138
         * Get tax_rate
139
         *
140
         * @return boolean
141
         */
142 46
        public function getTaxRate()
143
        {
144 46
            return $this->tax_rate;
145
        }
146
147
        /**
148
         * Has ClassCategory1
149
         *
150
         * @return boolean
151
         */
152 198
        public function hasClassCategory1()
153
        {
154 198
            return isset($this->ClassCategory1);
155
        }
156
157
        /**
158
         * Has ClassCategory1
159
         *
160
         * @return boolean
161
         */
162 198
        public function hasClassCategory2()
163
        {
164 198
            return isset($this->ClassCategory2);
165
        }
166
167
        /**
168
         * @var int
169
         *
170
         * @ORM\Column(name="id", type="integer", options={"unsigned":true})
171
         * @ORM\Id
172
         * @ORM\GeneratedValue(strategy="IDENTITY")
173
         */
174
        private $id;
175
176
        /**
177
         * @var string|null
178
         *
179
         * @ORM\Column(name="product_code", type="string", length=255, nullable=true)
180
         */
181
        private $code;
182
183
        /**
184
         * @var string|null
185
         *
186
         * @ORM\Column(name="stock", type="decimal", precision=10, scale=0, nullable=true)
187
         */
188
        private $stock;
189
190
        /**
191
         * @var boolean
192
         *
193
         * @ORM\Column(name="stock_unlimited", type="boolean", options={"default":false})
194
         */
195
        private $stock_unlimited = false;
196
197
        /**
198
         * @var string|null
199
         *
200
         * @ORM\Column(name="sale_limit", type="decimal", precision=10, scale=0, nullable=true, options={"unsigned":true})
201
         */
202
        private $sale_limit;
203
204
        /**
205
         * @var string|null
206
         *
207
         * @ORM\Column(name="price01", type="decimal", precision=12, scale=2, nullable=true)
208
         */
209
        private $price01;
210
211
        /**
212
         * @var string
213
         *
214
         * @ORM\Column(name="price02", type="decimal", precision=12, scale=2)
215
         */
216
        private $price02;
217
218
        /**
219
         * @var string|null
220
         *
221
         * @ORM\Column(name="delivery_fee", type="decimal", precision=12, scale=2, nullable=true, options={"unsigned":true})
222
         */
223
        private $delivery_fee;
224
225
        /**
226
         * @var boolean
227
         *
228
         * @ORM\Column(name="visible", type="boolean", options={"default":true})
229
         */
230
        private $visible;
231
232
        /**
233
         * @var \DateTime
234
         *
235
         * @ORM\Column(name="create_date", type="datetimetz")
236
         */
237
        private $create_date;
238
239
        /**
240
         * @var \DateTime
241
         *
242
         * @ORM\Column(name="update_date", type="datetimetz")
243
         */
244
        private $update_date;
245
246
        /**
247
         * @var string|null
248
         *
249
         * @ORM\Column(name="currency_code", type="string", nullable=true)
250
         */
251
        private $currency_code;
252
253
        /**
254
         * @var string
255
         *
256
         * @ORM\Column(name="point_rate", type="decimal", precision=10, scale=0, options={"unsigned":true}, nullable=true)
257
         */
258
        private $point_rate;
259
260
        /**
261
         * @var \Eccube\Entity\ProductStock
262
         *
263
         * @ORM\OneToOne(targetEntity="Eccube\Entity\ProductStock", mappedBy="ProductClass", cascade={"persist","remove"})
264
         */
265
        private $ProductStock;
266
267
        /**
268
         * @var \Eccube\Entity\TaxRule
269
         *
270
         * @ORM\OneToOne(targetEntity="Eccube\Entity\TaxRule", mappedBy="ProductClass", cascade={"persist","remove"})
271
         */
272
        private $TaxRule;
273
274
        /**
275
         * @var \Eccube\Entity\Product
276
         *
277
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Product", inversedBy="ProductClasses")
278
         * @ORM\JoinColumns({
279
         *   @ORM\JoinColumn(name="product_id", referencedColumnName="id")
280
         * })
281
         */
282
        private $Product;
283
284
        /**
285
         * @var \Eccube\Entity\Master\SaleType
286
         *
287
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Master\SaleType")
288
         * @ORM\JoinColumns({
289
         *   @ORM\JoinColumn(name="sale_type_id", referencedColumnName="id")
290
         * })
291
         */
292
        private $SaleType;
293
294
        /**
295
         * @var \Eccube\Entity\ClassCategory
296
         *
297
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\ClassCategory")
298
         * @ORM\JoinColumns({
299
         *   @ORM\JoinColumn(name="class_category_id1", referencedColumnName="id", nullable=true)
300
         * })
301
         */
302
        private $ClassCategory1;
303
304
        /**
305
         * @var \Eccube\Entity\ClassCategory
306
         *
307
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\ClassCategory")
308
         * @ORM\JoinColumns({
309
         *   @ORM\JoinColumn(name="class_category_id2", referencedColumnName="id", nullable=true)
310
         * })
311
         */
312
        private $ClassCategory2;
313
314
        /**
315
         * @var \Eccube\Entity\DeliveryDuration
316
         *
317
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\DeliveryDuration")
318
         * @ORM\JoinColumns({
319
         *   @ORM\JoinColumn(name="delivery_duration_id", referencedColumnName="id")
320
         * })
321
         */
322
        private $DeliveryDuration;
323
324
        /**
325
         * @var \Eccube\Entity\Member
326
         *
327
         * @ORM\ManyToOne(targetEntity="Eccube\Entity\Member")
328
         * @ORM\JoinColumns({
329
         *   @ORM\JoinColumn(name="creator_id", referencedColumnName="id")
330
         * })
331
         */
332
        private $Creator;
333
334 3
        public function __clone()
335
        {
336 3
            $this->id = null;
337
        }
338
339
        /**
340
         * Get id.
341
         *
342
         * @return int
343
         */
344 434
        public function getId()
345
        {
346 434
            return $this->id;
347
        }
348
349
        /**
350
         * Set code.
351
         *
352
         * @param string|null $code
353
         *
354
         * @return ProductClass
355
         */
356 406
        public function setCode($code = null)
357
        {
358 406
            $this->code = $code;
359
360 406
            return $this;
361
        }
362
363
        /**
364
         * Get code.
365
         *
366
         * @return string|null
367
         */
368 300
        public function getCode()
369
        {
370 300
            return $this->code;
371
        }
372
373
        /**
374
         * Set stock.
375
         *
376
         * @param string|null $stock
377
         *
378
         * @return ProductClass
379
         */
380 427
        public function setStock($stock = null)
381
        {
382 427
            $this->stock = $stock;
383
384 427
            return $this;
385
        }
386
387
        /**
388
         * Get stock.
389
         *
390
         * @return string|null
391
         */
392 278
        public function getStock()
393
        {
394 278
            return $this->stock;
395
        }
396
397
        /**
398
         * Set stockUnlimited.
399
         *
400
         * @param boolean $stockUnlimited
401
         *
402
         * @return ProductClass
403
         */
404 409
        public function setStockUnlimited($stockUnlimited)
405
        {
406 409
            $this->stock_unlimited = $stockUnlimited;
407
408 409
            return $this;
409
        }
410
411
        /**
412
         * Get stockUnlimited.
413
         *
414
         * @return boolean
415
         */
416 310
        public function isStockUnlimited()
417
        {
418 310
            return $this->stock_unlimited;
419
        }
420
421
        /**
422
         * Set saleLimit.
423
         *
424
         * @param string|null $saleLimit
425
         *
426
         * @return ProductClass
427
         */
428 33
        public function setSaleLimit($saleLimit = null)
429
        {
430 33
            $this->sale_limit = $saleLimit;
431
432 33
            return $this;
433
        }
434
435
        /**
436
         * Get saleLimit.
437
         *
438
         * @return string|null
439
         */
440 126
        public function getSaleLimit()
441
        {
442 126
            return $this->sale_limit;
443
        }
444
445
        /**
446
         * Set price01.
447
         *
448
         * @param string|null $price01
449
         *
450
         * @return ProductClass
451
         */
452 44
        public function setPrice01($price01 = null)
453
        {
454 44
            $this->price01 = $price01;
455
456 44
            return $this;
457
        }
458
459
        /**
460
         * Get price01.
461
         *
462
         * @return string|null
463
         */
464 481
        public function getPrice01()
465
        {
466 481
            return $this->price01;
467
        }
468
469
        /**
470
         * Set price02.
471
         *
472
         * @param string $price02
473
         *
474
         * @return ProductClass
475
         */
476 429
        public function setPrice02($price02)
477
        {
478 429
            $this->price02 = $price02;
479
480 429
            return $this;
481
        }
482
483
        /**
484
         * Get price02.
485
         *
486
         * @return string
487
         */
488 481
        public function getPrice02()
489
        {
490 481
            return $this->price02;
491
        }
492
493
        /**
494
         * Set deliveryFee.
495
         *
496
         * @param string|null $deliveryFee
497
         *
498
         * @return ProductClass
499
         */
500 25
        public function setDeliveryFee($deliveryFee = null)
501
        {
502 25
            $this->delivery_fee = $deliveryFee;
503
504 25
            return $this;
505
        }
506
507
        /**
508
         * Get deliveryFee.
509
         *
510
         * @return string|null
511
         */
512 45
        public function getDeliveryFee()
513
        {
514 45
            return $this->delivery_fee;
515
        }
516
517
        /**
518
         * @return boolean
519
         */
520 231
        public function isVisible()
521
        {
522 231
            return $this->visible;
523
        }
524
525
        /**
526
         * @param boolean $visible
527
         *
528
         * @return ProductClass
529
         */
530 414
        public function setVisible($visible)
531
        {
532 414
            $this->visible = $visible;
533
534 414
            return $this;
535
        }
536
537
        /**
538
         * Set createDate.
539
         *
540
         * @param \DateTime $createDate
541
         *
542
         * @return ProductClass
543
         */
544 408
        public function setCreateDate($createDate)
545
        {
546 408
            $this->create_date = $createDate;
547
548 408
            return $this;
549
        }
550
551
        /**
552
         * Get createDate.
553
         *
554
         * @return \DateTime
555
         */
556
        public function getCreateDate()
557
        {
558
            return $this->create_date;
559
        }
560
561
        /**
562
         * Set updateDate.
563
         *
564
         * @param \DateTime $updateDate
565
         *
566
         * @return ProductClass
567
         */
568 412
        public function setUpdateDate($updateDate)
569
        {
570 412
            $this->update_date = $updateDate;
571
572 412
            return $this;
573
        }
574
575
        /**
576
         * Get updateDate.
577
         *
578
         * @return \DateTime
579
         */
580
        public function getUpdateDate()
581
        {
582
            return $this->update_date;
583
        }
584
585
        /**
586
         * Get currencyCode.
587
         *
588
         * @return string
589
         */
590
        public function getCurrencyCode()
591
        {
592
            return $this->currency_code;
593
        }
594
595
        /**
596
         * Set currencyCode.
597
         *
598
         * @param string|null $currencyCode
599
         *
600
         * @return $this
601
         */
602 408
        public function setCurrencyCode($currencyCode = null)
603
        {
604 408
            $this->currency_code = $currencyCode;
605
606 408
            return $this;
607
        }
608
609
        /**
610
         * Set productStock.
611
         *
612
         * @param \Eccube\Entity\ProductStock|null $productStock
613
         *
614
         * @return ProductClass
615
         */
616 409
        public function setProductStock(\Eccube\Entity\ProductStock $productStock = null)
617
        {
618 409
            $this->ProductStock = $productStock;
619
620 409
            return $this;
621
        }
622
623
        /**
624
         * Get productStock.
625
         *
626
         * @return \Eccube\Entity\ProductStock|null
627
         */
628 35
        public function getProductStock()
629
        {
630 35
            return $this->ProductStock;
631
        }
632
633
        /**
634
         * Set taxRule.
635
         *
636
         * @param \Eccube\Entity\TaxRule|null $taxRule
637
         *
638
         * @return ProductClass
639
         */
640 10
        public function setTaxRule(\Eccube\Entity\TaxRule $taxRule = null)
641
        {
642 10
            $this->TaxRule = $taxRule;
643
644 10
            return $this;
645
        }
646
647
        /**
648
         * Get taxRule.
649
         *
650
         * @return \Eccube\Entity\TaxRule|null
651
         */
652 22
        public function getTaxRule()
653
        {
654 22
            return $this->TaxRule;
655
        }
656
657
        /**
658
         * Set product.
659
         *
660
         * @param \Eccube\Entity\Product|null $product
661
         *
662
         * @return ProductClass
663
         */
664 413
        public function setProduct(\Eccube\Entity\Product $product = null)
665
        {
666 413
            $this->Product = $product;
667
668 413
            return $this;
669
        }
670
671
        /**
672
         * Get product.
673
         *
674
         * @return \Eccube\Entity\Product|null
675
         */
676 463
        public function getProduct()
677
        {
678 463
            return $this->Product;
679
        }
680
681
        /**
682
         * Set saleType.
683
         *
684
         * @param \Eccube\Entity\Master\SaleType|null $saleType
685
         *
686
         * @return ProductClass
687
         */
688 408
        public function setSaleType(\Eccube\Entity\Master\SaleType $saleType = null)
689
        {
690 408
            $this->SaleType = $saleType;
691
692 408
            return $this;
693
        }
694
695
        /**
696
         * Get saleType.
697
         *
698
         * @return \Eccube\Entity\Master\SaleType|null
699
         */
700 149
        public function getSaleType()
701
        {
702 149
            return $this->SaleType;
703
        }
704
705
        /**
706
         * Set classCategory1.
707
         *
708
         * @param \Eccube\Entity\ClassCategory|null $classCategory1
709
         *
710
         * @return ProductClass
711
         */
712 411
        public function setClassCategory1(\Eccube\Entity\ClassCategory $classCategory1 = null)
713
        {
714 411
            $this->ClassCategory1 = $classCategory1;
715
716 411
            return $this;
717
        }
718
719
        /**
720
         * Get classCategory1.
721
         *
722
         * @return \Eccube\Entity\ClassCategory|null
723
         */
724 324
        public function getClassCategory1()
725
        {
726 324
            return $this->ClassCategory1;
727
        }
728
729
        /**
730
         * Set classCategory2.
731
         *
732
         * @param \Eccube\Entity\ClassCategory|null $classCategory2
733
         *
734
         * @return ProductClass
735
         */
736 285
        public function setClassCategory2(\Eccube\Entity\ClassCategory $classCategory2 = null)
737
        {
738 285
            $this->ClassCategory2 = $classCategory2;
739
740 285
            return $this;
741
        }
742
743
        /**
744
         * Get classCategory2.
745
         *
746
         * @return \Eccube\Entity\ClassCategory|null
747
         */
748 272
        public function getClassCategory2()
749
        {
750 272
            return $this->ClassCategory2;
751
        }
752
753
        /**
754
         * Set deliveryDuration.
755
         *
756
         * @param \Eccube\Entity\DeliveryDuration|null $deliveryDuration
757
         *
758
         * @return ProductClass
759
         */
760 397
        public function setDeliveryDuration(\Eccube\Entity\DeliveryDuration $deliveryDuration = null)
761
        {
762 397
            $this->DeliveryDuration = $deliveryDuration;
763
764 397
            return $this;
765
        }
766
767
        /**
768
         * Get deliveryDuration.
769
         *
770
         * @return \Eccube\Entity\DeliveryDuration|null
771
         */
772 96
        public function getDeliveryDuration()
773
        {
774 96
            return $this->DeliveryDuration;
775
        }
776
777
        /**
778
         * Set creator.
779
         *
780
         * @param \Eccube\Entity\Member|null $creator
781
         *
782
         * @return ProductClass
783
         */
784 412
        public function setCreator(\Eccube\Entity\Member $creator = null)
785
        {
786 412
            $this->Creator = $creator;
787
788 412
            return $this;
789
        }
790
791
        /**
792
         * Get creator.
793
         *
794
         * @return \Eccube\Entity\Member|null
795
         */
796
        public function getCreator()
797
        {
798
            return $this->Creator;
799
        }
800
801
        /**
802
         * Set pointRate
803
         *
804
         * @param string $pointRate
805
         *
806
         * @return ProductClass
807
         */
808
        public function setPointRate($pointRate)
809
        {
810
            $this->point_rate = $pointRate;
811
812
            return $this;
813
        }
814
815
        /**
816
         * Get pointRate
817
         *
818
         * @return string
819
         */
820
        public function getPointRate()
821
        {
822
            return $this->point_rate;
823
        }
824
    }
825
}
826