LessThanHavingFilter::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\HavingFilters;
5
6
class LessThanHavingFilter implements HavingFilterInterface
7
{
8
    protected string $metric;
9
10
    protected float $value;
11
12
    /**
13
     * LessThanHavingFilter constructor.
14
     *
15
     * @param string $metric
16
     * @param float  $value
17
     */
18 4
    public function __construct(string $metric, float $value)
19
    {
20 4
        $this->metric = $metric;
21 4
        $this->value  = $value;
22
    }
23
24
    /**
25
     * Return the having filter as it can be used in a druid query.
26
     *
27
     * @return array<string,string|float>
28
     */
29 4
    public function toArray(): array
30
    {
31 4
        return [
32 4
            'type'        => 'lessThan',
33 4
            'aggregation' => $this->metric,
34 4
            'value'       => $this->value,
35 4
        ];
36
    }
37
}