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

ElasticsearchAdminException::esNotEnabled()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
b 0
f 0
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