ExpressionTransform   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Transforms;
5
6
class ExpressionTransform implements TransformInterface
7
{
8
    protected string $outputName;
9
10
    protected string $expression;
11
12
    /**
13
     * ExpressionTransform constructor.
14
     *
15
     * @param string $expression
16
     * @param string $outputName
17
     */
18 6
    public function __construct(string $expression, string $outputName)
19
    {
20 6
        $this->expression = $expression;
21 6
        $this->outputName = $outputName;
22
    }
23
24
    /**
25
     * Return the transform in such a way so that we can use it in a druid query.
26
     *
27
     * @return array<string,string>
28
     */
29 4
    public function toArray(): array
30
    {
31 4
        return [
32 4
            'type'       => 'expression',
33 4
            'name'       => $this->outputName,
34 4
            'expression' => $this->expression,
35 4
        ];
36
    }
37
}