Passed
Pull Request — master (#38)
by Teye
05:25
created

PrefixFilteredDimension::getDimension()   A

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 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Dimensions;
5
6
class PrefixFilteredDimension implements DimensionInterface
7
{
8
    protected Dimension $dimension;
9
10
    protected string $prefix;
11
12
    /**
13
     * PrefixFilteredDimension constructor.
14
     *
15
     * @param Dimension $dimension
16
     * @param string    $prefix
17
     */
18 1
    public function __construct(Dimension $dimension, string $prefix)
19
    {
20 1
        $this->dimension = $dimension;
21 1
        $this->prefix    = $prefix;
22
    }
23
24
    /**
25
     * Return the dimension as it should be used in a druid query.
26
     *
27
     * @return array<string,string|array<mixed>>
28
     */
29 1
    public function toArray(): array
30
    {
31
        return [
32 1
            'type'     => 'prefixFiltered',
33 1
            'delegate' => $this->dimension->toArray(),
34 1
            'prefix'   => $this->prefix,
35
        ];
36
    }
37
38
    /**
39
     * Return the name of the dimension which is selected.
40
     *
41
     * @return string
42
     */
43 1
    public function getDimension(): string
44
    {
45 1
        return $this->dimension->getDimension();
46
    }
47
48
    /**
49
     * Return the output name of this dimension
50
     *
51
     * @return string
52
     */
53 1
    public function getOutputName(): string
54
    {
55 1
        return $this->dimension->getOutputName();
56
    }
57
}