Passed
Push — trunk ( 17375e...d9bd07 )
by Christian
12:35 queued 12s
created

ThemeException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A themeMediaStillInUse() 0 6 1
A salesChannelNotFound() 0 7 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Storefront\Theme\Exception;
4
5
use Shopware\Core\Framework\HttpException;
6
use Shopware\Core\Framework\Log\Package;
7
use Symfony\Component\HttpFoundation\Response;
8
9
#[Package('storefront')]
10
class ThemeException extends HttpException
11
{
12
    public const THEME_MEDIA_IN_USE_EXCEPTION = 'THEME__MEDIA_IN_USE_EXCEPTION';
13
    public const THEME_SALES_CHANNEL_NOT_FOUND = 'THEME__SALES_CHANNEL_NOT_FOUND';
14
15
    public static function themeMediaStillInUse(): self
16
    {
17
        return new self(
18
            Response::HTTP_BAD_REQUEST,
19
            self::THEME_MEDIA_IN_USE_EXCEPTION,
20
            'Media entity is still in use by a theme'
21
        );
22
    }
23
24
    public static function salesChannelNotFound(string $salesChannelId): self
25
    {
26
        return new self(
27
            Response::HTTP_BAD_REQUEST,
28
            self::THEME_SALES_CHANNEL_NOT_FOUND,
29
            'The sales channel with the id {{ id }} could not be found',
30
            ['id' => $salesChannelId]
31
        );
32
    }
33
}
34