Completed
Pull Request — experimental/3.1 (#2154)
by Kentaro
448:33 queued 441:10
created

TaxStrategy   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 15.63 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 5
loc 32
rs 10
c 0
b 0
f 0
ccs 13
cts 13
cp 1
wmc 5
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A execute() 5 9 2
A setApplication() 0 5 1
A setOrder() 0 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Eccube\Service\Calculator\Strategy;
4
5
use Eccube\Application;
6
use Eccube\Entity\Order;
7
use Eccube\Entity\OrderDetail;
8
use Eccube\Service\Calculator\OrderDetailCollection;
9
10
class TaxStrategy implements CalculateStrategyInterface
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
11
{
12
    protected $app;
13
    protected $Order;
14
15 12
    public function __construct(Application $app = null)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
16
    {
17 12
        $this->app = $app;
18
    }
19
20 12
    public function execute(OrderDetailCollection $OrderDetails)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
21
    {
22
        // map でやりたい
23 12 View Code Duplication
        foreach ($OrderDetails as $OrderDetail) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
24 12
            $tax = $this->app['eccube.service.tax_rule']
25 12
                ->calcTax($OrderDetail->getPrice(), $OrderDetail->getTaxRate(), $OrderDetail->getTaxRule());
26 12
            $OrderDetail->setPriceIncTax($OrderDetail->getPrice() + $tax);
27
        }
28
    }
29
30 12
    public function setApplication(Application $app)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
31
    {
32 12
        $this->app = $app;
33 12
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
34
    }
35
36 12
    public function setOrder(Order $Order)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
37
    {
38 12
        $this->Order = $Order;
39 12
        return $this;
0 ignored issues
show
introduced by
Missing blank line before return statement
Loading history...
40
    }
41
}
42