Failed Conditions
Pull Request — experimental/3.1 (#2449)
by Kiyotaka
52:40
created

ShippingStrategy::setOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 3
cp 0
crap 2
1
<?php
2
namespace Eccube\Service\Calculator\Strategy;
3
4
use Eccube\Application;
5
use Eccube\Entity\Master\OrderItemType;
6
use Eccube\Entity\Master\TaxType;
7
use Eccube\Entity\Master\TaxDisplayType;
8
use Eccube\Entity\Order;
9
use Eccube\Entity\PurchaseInterface;
10
use Eccube\Entity\ShipmentItem;
11
use Eccube\Entity\Shipping;
12
use Eccube\Repository\Master\OrderItemTypeRepository;
13
use Eccube\Service\Calculator\ShipmentItemCollection;
14
15
class ShippingStrategy implements CalculateStrategyInterface
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
16
{
17
    /* @var Application $app */
18
    protected $app;
19
20
    /* @var Order $Order */
21
    protected $Order;
22
23
    /** @var OrderItemTypeRepository */
24
    protected $OrderItemTypeRepository;
25
26
    public function execute(ShipmentItemCollection $ShipmentItems)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
27
    {
28
        // 送料の受注明細区分
29
        $DeliveryFeeType = $this->app['eccube.repository.master.order_item_type']->find(OrderItemType::DELIVERY_FEE);
30
        // TODO
31
        $TaxInclude = $this->app['orm.em']->getRepository(TaxDisplayType::class)->find(TaxDisplayType::INCLUDED);
32
        $Taxion = $this->app['orm.em']->getRepository(TaxType::class)->find(TaxType::TAXATION);
33
34
        // 配送ごとに送料の明細を作成
35
        foreach ($this->Order->getShippings() as $Shipping) {
36
            /* @var Shipping $Shipping */
37
            $sio = new ShipmentItemCollection($Shipping->getShipmentItems()->toArray());
38 View Code Duplication
            if (!$sio->hasItemByOrderItemType($DeliveryFeeType)) {
39
                $ShipmentItem = new ShipmentItem();
40
                $ShipmentItem->setProductName("送料")
41
                    ->setPrice($Shipping->getShippingDeliveryFee())
42
                    ->setPriceIncTax($Shipping->getShippingDeliveryFee())
43
                    ->setTaxRate(8)
44
                    ->setQuantity(1)
45
                    ->setOrderItemType($DeliveryFeeType)
46
                    ->setShipping($Shipping)
47
                    ->setTaxDisplayType($TaxInclude)
48
                    ->setTaxType($Taxion);
49
                $ShipmentItems->add($ShipmentItem);
50
                $Shipping->addShipmentItem($ShipmentItem);
51
            }
52
        }
53
    }
54
55
    public function setApplication(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
56
    {
57
        $this->app = $app;
58
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
59
    }
60
61
    public function setOrder(PurchaseInterface $Order)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
62
    {
63
        $this->Order = $Order;
0 ignored issues
show
Documentation Bug introduced by
It seems like $Order of type object<Eccube\Entity\PurchaseInterface> is incompatible with the declared type object<Eccube\Entity\Order> of property $Order.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
64
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
65
    }
66
67
    public function getTargetTypes()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
68
    {
69
        return [Order::class];
70
    }
71
}
72