Failed Conditions
Push — experimental/3.1 ( 5e26c8...ed1771 )
by Kiyotaka
162:23 queued 151:58
created

CalculateTotalStrategy::setApplication()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 5
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\Cart;
9
use Eccube\Entity\Order;
10
use Eccube\Entity\PurchaseInterface;
11
use Eccube\Entity\ShipmentItem;
12
use Eccube\Entity\Shipping;
13
use Eccube\Repository\Master\OrderItemTypeRepository;
14
use Eccube\Service\Calculator\ShipmentItemCollection;
15
16
/**
17
 * 明細の合計を集計して Order にセットする.
18
 */
19 View Code Duplication
class CalculateTotalStrategy implements CalculateStrategyInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /* @var Application $app */
22
    protected $app;
23
24
    /* @var Order $Order */
25
    protected $Order;
26
27
    /** @var OrderItemTypeRepository */
28
    protected $OrderItemTypeRepository;
29
30
    public function execute(ShipmentItemCollection $ShipmentItems)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
31
    {
32
        $total = $ShipmentItems->reduce(
33
            function($total, $ShipmentItem) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
34
                return $total + $ShipmentItem->getPrice() * $ShipmentItem->getQuantity();
35
            }, 0
36
        );
37
        $this->Order->setTotal($total);
38
    }
39
40
    public function setApplication(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
41
    {
42
        $this->app = $app;
43
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
44
    }
45
46
    public function setOrder(PurchaseInterface $Order)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
47
    {
48
        $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...
49
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
50
    }
51
52
    public function getTargetTypes()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
53
    {
54
        return [Order::class, Cart::class];
55
    }
56
}
57