TransformBuilder::transform()   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
eloc 2
c 0
b 0
f 0
dl 0
loc 5
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
use Level23\Druid\Concerns\HasFilter;
7
8
class TransformBuilder
9
{
10
    use HasFilter;
11
12
    /**
13
     * @var array|\Level23\Druid\Transforms\TransformInterface[]
14
     */
15
    protected array $transforms = [];
16
17
    /**
18
     * Build a new transform.
19
     *
20
     * For all the available options in expressions, see this link:
21
     *
22
     * @see https://druid.apache.org/docs/latest/misc/math-expr.html
23
     *
24
     * @param string $expression
25
     * @param string $as
26
     *
27
     * @return self
28
     */
29 2
    public function transform(string $expression, string $as): self
30
    {
31 2
        $this->transforms[] = new ExpressionTransform($expression, $as);
32
33 2
        return $this;
34
    }
35
36
    /**
37
     * @return array|\Level23\Druid\Transforms\TransformInterface[]
38
     */
39 3
    public function getTransforms(): array
40
    {
41 3
        return $this->transforms;
42
    }
43
}