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

PrefixFilteredDimension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 11
c 0
b 0
f 0
dl 0
loc 50
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 6 1
A __construct() 0 4 1
A getOutputName() 0 3 1
A getDimension() 0 3 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
}