Completed
Pull Request — experimental/3.1 (#2479)
by chihiro
65:40 queued 24:05
created

DisplayStatusValidator   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 20
loc 20
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1
wmc 5
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 10 10 3
A handle() 6 6 2

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\PurchaseFlow\Processor;
4
5
use Eccube\Entity\CartItem;
6
use Eccube\Entity\ItemInterface;
7
use Eccube\Service\PurchaseFlow\ItemValidateException;
8
use Eccube\Service\PurchaseFlow\PurchaseContext;
9
use Eccube\Service\PurchaseFlow\ValidatableItemProcessor;
10
11 View Code Duplication
class DisplayStatusValidator extends ValidatableItemProcessor
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...
introduced by
Missing class doc comment
Loading history...
12
{
13 17
    protected function validate(ItemInterface $item, PurchaseContext $context)
14
    {
15 17
        if (!$item->isProduct()) {
16 2
            return;
17
        }
18 17
        $ProductClass = $item->getProductClass();
19 17
        if (!$ProductClass->isEnable()) {
20 1
            throw new ItemValidateException('cart.product.not.status');
21
        }
22
    }
23
24 1
    protected function handle(ItemInterface $item, PurchaseContext $context)
25
    {
26 1
        if ($item instanceof CartItem) {
27 1
            $item->setQuantity(0);
28
        }
29
    }
30
}
31