Passed
Push — trunk ( 325349...f71779 )
by Christian
12:37 queued 16s
created

ElasticsearchIndexingException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexingError() 0 3 1
A definitionNotFound() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Elasticsearch\Framework\Indexing;
4
5
use Shopware\Core\Framework\HttpException;
6
use Shopware\Core\Framework\Log\Package;
7
use Shopware\Core\Framework\ShopwareHttpException;
8
use Shopware\Elasticsearch\Exception\ElasticsearchIndexingException as IndexingError;
9
use Symfony\Component\HttpFoundation\Response;
10
11
#[Package('core')]
12
class ElasticsearchIndexingException extends HttpException
13
{
14
    public const ES_DEFINITION_NOT_FOUND = 'ELASTICSEARCH_INDEXING__DEFINITION_NOT_FOUND';
15
16
    public const ES_INDEXING_ERROR = 'ELASTICSEARCH_INDEXING__INDEXING_ERROR';
17
18
    public static function definitionNotFound(string $definition): self
19
    {
20
        return new self(
21
            Response::HTTP_BAD_REQUEST,
22
            self::ES_DEFINITION_NOT_FOUND,
23
            sprintf('Elasticsearch definition of %s not found', $definition),
24
        );
25
    }
26
27
    /**
28
     * @param array{index: string, id: string, type: string, reason: string}[] $errors
29
     */
30
    public static function indexingError(array $errors): ShopwareHttpException
31
    {
32
        return new IndexingError($errors);
33
    }
34
}
35