Passed
Push — master ( 08b37c...1ffe05 )
by Mike
02:17
created

ElasticsearchFacade::deleteDocuments()   A

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