ElasticsearchFacade::createIndizes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\Elasticsearch\Business;
5
6
7
use DataProvider\DocumentListDataProvider;
0 ignored issues
show
Bug introduced by
The type DataProvider\DocumentListDataProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use DataProvider\ElasticsearchResultSetDataProvider;
0 ignored issues
show
Bug introduced by
The type DataProvider\ElasticsearchResultSetDataProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Elastica\Query;
10
use Xervice\Core\Business\Model\Facade\AbstractFacade;
11
use Xervice\DataProvider\Business\Model\DataProvider\DataProviderInterface;
12
13
/**
14
 * @method \Xervice\Elasticsearch\Business\ElasticsearchBusinessFactory getFactory()
15
 * @method \Xervice\Elasticsearch\ElasticsearchConfig getConfig()
16
 */
17
class ElasticsearchFacade extends AbstractFacade implements ElasticsearchFacadeInterface
18
{
19
    /**
20
     * Generate all indizes in elasticsearch
21
     *
22
     * @api
23
     */
24 1
    public function createIndizes(): void
25
    {
26
        $this
27 1
            ->getFactory()
28 1
            ->createIndexer()
29 1
            ->createIndizes();
30 1
    }
31
32
    /**
33
     * @param string $dataProviderClass
34
     *
35
     * @return array
36
     */
37
    public function getMapping(string $dataProviderClass): array
38
    {
39
        return $this
40
            ->getFactory()
41
            ->createMappingConverter()
42
            ->convertToMapping($dataProviderClass);
43
    }
44
45
    /**
46
     * Create a list of documents in elasticsearch
47
     *
48
     * @api
49
     *
50
     * @param \DataProvider\DocumentListDataProvider $listDataProvider
51
     */
52 1
    public function createDocuments(DocumentListDataProvider $listDataProvider): void
53
    {
54
        $this
55 1
            ->getFactory()
56 1
            ->createDocumentBuilder()
57 1
            ->createDocuments($listDataProvider);
58 1
    }
59
60
    /**
61
     * Remove a list of documents in elasticsearch
62
     *
63
     * @api
64
     *
65
     * @param \DataProvider\DocumentListDataProvider $listDataProvider
66
     */
67 1
    public function deleteDocuments(DocumentListDataProvider $listDataProvider): void
68
    {
69
        $this
70 1
            ->getFactory()
71 1
            ->createDocumentCleaner()
72 1
            ->deleteDocuments($listDataProvider);
73 1
    }
74
75
    /**
76
     * Send search request to elasticsearch
77
     * QueryExtenderPlugins can extend the query
78
     * ResultFormatterPlugins can format the result DataProvider
79
     *
80
     * @api
81
     *
82
     * @param string $index
83
     * @param \Elastica\Query $query
84
     * @param array $queryExtender
85
     * @param array $resultFormatter
86
     *
87
     * @return \DataProvider\ElasticsearchResultSetDataProvider
88
     */
89 1
    public function search(
90
        string $index,
91
        Query $query,
92
        array $queryExtender = [],
93
        array $resultFormatter = []
94
    ): ElasticsearchResultSetDataProvider {
95
        return $this
96 1
            ->getFactory()
97 1
            ->createSearch($queryExtender, $resultFormatter)
98 1
            ->search($index, $query);
99
    }
100
}