ExpressionFilter::__construct()   A
last analyzed

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 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Filters;
5
6
/**
7
 * Class ExpressionFilter
8
 *
9
 * The expression filter allows for the implementation of arbitrary conditions, leveraging the Druid expression system.
10
 *
11
 * @package Level23\Druid\Filters
12
 */
13
class ExpressionFilter implements FilterInterface
14
{
15
    protected string $expression;
16
17
    /**
18
     * @param string $expression
19
     */
20 2
    public function __construct(string $expression)
21
    {
22 2
        $this->expression = $expression;
23
    }
24
25
    /**
26
     * Return the filter as it can be used in the druid query.
27
     *
28
     * @return array<string,string>
29
     */
30 2
    public function toArray(): array
31
    {
32 2
        return [
33 2
            'type'       => 'expression',
34 2
            'expression' => $this->expression,
35 2
        ];
36
    }
37
}