Passed
Push — trunk ( fd0441...5431f0 )
by Christian
11:15 queued 14s
created

ElasticsearchAdminException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A esNotEnabled() 0 6 1
A missingTermParameter() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Elasticsearch\Admin;
4
5
use Shopware\Core\Framework\HttpException;
6
use Shopware\Core\Framework\Log\Package;
7
use Symfony\Component\HttpFoundation\Response;
8
9
#[Package('system-settings')]
10
class ElasticsearchAdminException extends HttpException
11
{
12
    public const ADMIN_ELASTIC_SEARCH_NOT_ENABLED = 'ELASTICSEARCH__ADMIN_ES_NOT_ENABLED';
13
    public const TERM_PARAMETER_IS_MISSING = 'ELASTICSEARCH__TERM_PARAMETER_IS_MISSING';
14
15
    public static function esNotEnabled(): self
16
    {
17
        return new self(
18
            Response::HTTP_SERVICE_UNAVAILABLE,
19
            self::ADMIN_ELASTIC_SEARCH_NOT_ENABLED,
20
            'Admin elasticsearch is not enabled',
21
        );
22
    }
23
24
    public static function missingTermParameter(): self
25
    {
26
        return new self(
27
            Response::HTTP_BAD_REQUEST,
28
            self::TERM_PARAMETER_IS_MISSING,
29
            'Parameter "term" is missing.',
30
        );
31
    }
32
}
33