Passed
Push — master ( f51d93...08b37c )
by Mike
02:59
created

ElasticsearchFacade::search()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
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 4
dl 0
loc 10
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
     * Send search request to elasticsearch
51
     * QueryExtenderPlugins can extend the query
52
     * ResultFormatterPlugins can format the result DataProvider
53
     *
54
     * @api
55
     *
56
     * @param string $index
57
     * @param \Elastica\Query $query
58
     * @param array $queryExtender
59
     * @param array $resultFormatter
60
     *
61
     * @return \DataProvider\ElasticsearchResultSetDataProvider
62
     */
63 1
    public function search(
64
        string $index,
65
        Query $query,
66
        array $queryExtender = [],
67
        array $resultFormatter = []
68
    ): ElasticsearchResultSetDataProvider {
69
        return $this
70 1
            ->getFactory()
71 1
            ->createSearch($queryExtender, $resultFormatter)
72 1
            ->search($index, $query);
73
    }
74
}