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

QueryBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
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\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
}