Passed
Push — trunk ( ad06ea...8f56e6 )
by Christian
23:45 queued 17s
created

PromotionException::codeAlreadyRedeemed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Promotion;
4
5
use Shopware\Core\Framework\HttpException;
6
use Shopware\Core\Framework\Log\Package;
7
use Symfony\Component\HttpFoundation\Response;
8
9
#[Package('checkout')]
10
class PromotionException extends HttpException
11
{
12
    public const PROMOTION_CODE_ALREADY_REDEEMED = 'CHECKOUT__CODE_ALREADY_REDEEMED';
13
14
    public static function codeAlreadyRedeemed(string $code): self
15
    {
16
        return new self(
17
            Response::HTTP_BAD_REQUEST,
18
            self::PROMOTION_CODE_ALREADY_REDEEMED,
19
            'Promotion with code "{{ code }}" has already been marked as redeemed!',
20
            ['code' => $code]
21
        );
22
    }
23
}
24