Completed
Pull Request — experimental/sf (#3265)
by Kiyotaka
41:07 queued 06:58
created

InvalidItemException::isWarning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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\ProductClass;
17
18
class InvalidItemException extends \Exception
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
19
{
20
    private $messageArgs = [];
21
22
    private $warning;
23
24 72
    public function __construct($message = null, $messageArgs = [], $warning = false)
25
    {
26 72
        parent::__construct($message);
27 72
        $this->messageArgs = $messageArgs;
28 72
        $this->warning = $warning;
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    public function getMessageArgs()
35
    {
36
        return $this->messageArgs;
37
    }
38
39
    /**
40
     * @return bool
41
     */
42 14
    public function isWarning()
43
    {
44 14
        return $this->warning;
45
    }
46
47
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$errorMessage" missing
Loading history...
introduced by
Doc comment for parameter "$ProductClass" missing
Loading history...
48
     * @return InvalidItemException
49
     */
50 View Code Duplication
    public static function fromProductClass($errorMessage, ProductClass $ProductClass)
0 ignored issues
show
Duplication introduced by
This method 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...
51
    {
52
        $productName = $ProductClass->getProduct()->getName();
53
        if ($ProductClass->hasClassCategory1()) {
54
            $productName .= ' - '.$ProductClass->getClassCategory1()->getName();
55
        }
56
        if ($ProductClass->hasClassCategory2()) {
57
            $productName .= ' - '.$ProductClass->getClassCategory2()->getName();
58
        }
59
60
        return new self($errorMessage, ['%product%' => $productName]);
61
    }
62
}
63