ExpressionTransform::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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
}