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

PromotionException   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 12
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A codeAlreadyRedeemed() 0 7 1
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