Completed
Pull Request — 4.0 (#4223)
by Kentaro
04:57
created

ItemHolderValidator::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 4
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.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 ItemHolderValidator
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 274
    final public function execute(ItemHolderInterface $itemHolder, PurchaseContext $context)
32
    {
33
        try {
34 274
            $this->validate($itemHolder, $context);
35
36 260
            return ProcessResult::success(null, static::class);
37 21
        } catch (InvalidItemException $e) {
38 21
            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
    protected function handle(ItemHolderInterface $itemHolder)
0 ignored issues
show
Unused Code introduced by
The parameter $itemHolder is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
    }
55
56
    public function __toString()
57
    {
58
        return get_class($this);
59
    }
60
}
61