ElasticsearchDsl   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 42
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getEsClient() 0 3 1
A suggest() 0 4 1
A search() 0 9 1
1
<?php
2
namespace Triadev\Es\Dsl;
3
4
use Elasticsearch\Client;
5
use ONGR\ElasticsearchDSL\Search as OngrSearch;
6
use Triadev\Es\Contract\ElasticsearchContract;
7
use Triadev\Es\Dsl\Contract\ElasticsearchDslContract;
8
use Triadev\Es\Dsl\Dsl\Search;
9
use Triadev\Es\Dsl\Dsl\Suggestion;
10
11
class ElasticsearchDsl implements ElasticsearchDslContract
12
{
13
    /**
14
     * Get es client
15
     *
16
     * @return Client
17
     */
18 1
    public function getEsClient(): Client
19
    {
20 1
        return app(ElasticsearchContract::class)->getClient();
21
    }
22
    
23
    /**
24
     * Search
25
     *
26
     * @param OngrSearch|null $search
27
     * @param string|null $esIndex
28
     * @param string|null $esType
29
     * @return Search
30
     */
31 14
    public function search(
32
        ?OngrSearch $search = null,
33
        ?string $esIndex = null,
34
        ?string $esType = null
35
    ): Search {
36 14
        return app()->makeWith(Search::class, [
37 14
            'search' => $search,
38 14
            'esIndex' => $esIndex,
39 14
            'esType' => $esType
40
        ]);
41
    }
42
    
43
    /**
44
     * Suggestion
45
     *
46
     * @param OngrSearch|null $search
47
     * @return Suggestion
48
     */
49 3
    public function suggest(?OngrSearch $search = null): Suggestion
50
    {
51 3
        return app()->makeWith(Suggestion::class, [
52 3
            'search' => $search
53
        ]);
54
    }
55
}
56