Failed Conditions
Push — sf/last-boss ( 53d963...58156b )
by Kiyotaka
09:54 queued 04:25
created

ItemHolderPostValidator::execute()   A

Complexity

Conditions 3
Paths 5

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
nc 5
nop 2
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Service\PurchaseFlow;
15
16
use Eccube\Entity\ItemHolderInterface;
17
18
/**
19
 * カート/受注の妥当性検証を行う.
20
 */
21 View Code Duplication
abstract class ItemHolderPostValidator
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...
22
{
23
    use ValidatorTrait;
24
25
    /**
26
     * @param ItemHolderInterface $itemHolder
27
     * @param PurchaseContext $context
28
     *
29
     * @return ProcessResult
30
     */
31
    final public function execute(ItemHolderInterface $itemHolder, PurchaseContext $context)
32
    {
33
        try {
34
            $this->validate($itemHolder, $context);
35
36
            return ProcessResult::success(null, static::class);
37
        } catch (InvalidItemException $e) {
38
            return $e->isWarning()
39
                ? ProcessResult::warn($e->getMessage(), static::class)
40
                : ProcessResult::error($e->getMessage(), static::class);
41
        }
42
    }
43
44
    /**
45
     * @param ItemHolderInterface $itemHolder
46
     * @param PurchaseContext $context
47
     *
48
     * @throws InvalidItemException
49
     */
50
    abstract protected function validate(ItemHolderInterface $itemHolder, PurchaseContext $context);
51
}
52