ConstantScoreQuery   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 1
b 0
f 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 12 2
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Search\Query\Compound;
4
5
use Nord\Lumen\Elasticsearch\Exceptions\InvalidArgument;
6
use Nord\Lumen\Elasticsearch\Search\Query\Traits\HasBoost;
7
use Nord\Lumen\Elasticsearch\Search\Query\Traits\HasQuery;
8
9
/**
10
 * Class ConstantScoreQuery
11
 * @package Nord\Lumen\Elasticsearch\Search\Query\Compound
12
 */
13
class ConstantScoreQuery extends AbstractQuery
14
{
15
    use HasQuery;
16
    use HasBoost;
17
18
    /**
19
     * @inheritdoc
20
     * @throws InvalidArgument
21
     */
22
    public function toArray()
23
    {
24
        $query = $this->getQuery();
25
26
        if ($query === null) {
27
            throw new InvalidArgument('Query must be set');
28
        }
29
30
        return [
31
            'constant_score' => [
32
                'filter' => $query->toArray(),
33
                'boost'  => $this->getBoost(),
34
            ],
35
        ];
36
    }
37
}
38