Boolean::must()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is part of PhpStorm.
4
 *
5
 * (c) PHPinnacle Team <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace PHPinnacle\Elastics\Query;
14
15
use PHPinnacle\Elastics\Query;
16
use PHPinnacle\Elastics\Traits;
17
18
class Boolean implements Query
19
{
20
    use Traits\Boost;
21
22
    /**
23
     * @var array
24
     */
25
    private $must = [];
26
27
    /**
28
     * @var array
29
     */
30
    private $mustNot = [];
31
32
    /**
33
     * @var array
34
     */
35
    private $should = [];
36
37
    /**
38
     * @var array
39
     */
40
    private $filter = [];
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 1
    public function must(Query ...$queries): self
46
    {
47 1
        $this->must = \array_merge($this->must, $queries);
48
49 1
        return $this;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function mustNot(Query ...$queries): self
56
    {
57 1
        $this->mustNot = \array_merge($this->mustNot, $queries);
58
59 1
        return $this;
60
    }
61
62
    /**
63
     * {@inheritdoc}
64
     */
65 1
    public function should(Query ...$queries): self
66
    {
67 1
        $this->should = \array_merge($this->should, $queries);
68
69 1
        return $this;
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75 1
    public function filter(Query ...$queries): self
76
    {
77 1
        $this->filter = \array_merge($this->filter, $queries);
78
79 1
        return $this;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85 1
    public function name(): string
86
    {
87 1
        return 'bool';
88
    }
89
90
    /**
91
     * @return array
92
     */
93 4
    public function compile(): array
94
    {
95 4
        return \array_filter([
96 4
            'must'     => \elastics_compile(...$this->must),
97 4
            'must_not' => \elastics_compile(...$this->mustNot),
98 4
            'should'   => \elastics_compile(...$this->should),
99 4
            'filter'   => \elastics_compile(...$this->filter),
100
        ]);
101
    }
102
}
103