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

QueryBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 29
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getQuery() 0 7 2
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\Elasticsearch\Business\Model\Search\Query;
5
6
7
use Elastica\Query;
8
9
class QueryBuilder implements QueryBuilderInterface
10
{
11
    /**
12
     * @var \Xervice\Elasticsearch\Dependency\Plugin\QueryExtenderPluginInterface[]
13
     */
14
    private $queryExtenderPlugins;
15
16
    /**
17
     * QueryBuilder constructor.
18
     *
19
     * @param \Xervice\Elasticsearch\Dependency\Plugin\QueryExtenderPluginInterface[] $queryExtenderPlugins
20
     */
21 1
    public function __construct(array $queryExtenderPlugins)
22
    {
23 1
        $this->queryExtenderPlugins = $queryExtenderPlugins;
24 1
    }
25
26
    /**
27
     * @param \Elastica\Query $query
28
     *
29
     * @return \Elastica\Query
30
     */
31 1
    public function getQuery(Query $query): Query
32
    {
33 1
        foreach ($this->queryExtenderPlugins as $extenderPlugin) {
34
            $query = $extenderPlugin->extendQuery($query);
35
        }
36
37 1
        return $query;
38
    }
39
}