Completed
Push — sf/csv-headers ( 829ce9...de2c5f )
by Kiyotaka
06:12
created

InvalidItemException::isWarning()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
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
19
{
20
    private $messageArgs = [];
21
22
    private $warning;
23
24
    public function __construct($message = null, $messageArgs = [], $warning = false)
25
    {
26
        parent::__construct($message);
27
        $this->messageArgs = $messageArgs;
28
        $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
    public function isWarning()
43
    {
44
        return $this->warning;
45
    }
46
47
    /**
48
     * @return InvalidItemException
49
     */
50
    public static function fromProductClass($errorMessage, ProductClass $ProductClass)
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