Failed Conditions
Pull Request — experimental/3.1 (#2374)
by Kentaro
119:10 queued 111:16
created

ChargeStrategy::setApplication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

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
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 ChargeStrategy 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
        $ChargeType = $this->app['eccube.repository.master.order_item_type']->find(OrderItemType::CHARGE);
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 View Code Duplication
        if (!$ShipmentItems->hasItemByOrderItemType($ChargeType)) {
35
            $Payment = $this->Order->getPayment();
36
            if (is_object($Payment) && $Payment->getCharge() > 0) {
37
                $ShipmentItem = new ShipmentItem();
38
                $ShipmentItem->setProductName("手数料")
39
                    ->setPrice($Payment->getCharge())
40
                    ->setPriceIncTax($Payment->getCharge())
41
                    ->setTaxRate(8)
42
                    ->setQuantity(1)
43
                    ->setOrderItemType($ChargeType)
44
                    ->setTaxDisplayType($TaxInclude)
45
                    ->setTaxType($Taxion);
46
                $ShipmentItems->add($ShipmentItem);
47
            }
48
        }
49
    }
50
51
    public function setApplication(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
52
    {
53
        $this->app = $app;
54
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
55
    }
56
57
    public function setOrder(PurchaseInterface $Order)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
58
    {
59
        $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...
60
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
61
    }
62
63
    public function getTargetTypes()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
64
    {
65
        return [Order::class];
66
    }
67
}
68