FieldAccessPostAggregator::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\PostAggregations;
5
6
class FieldAccessPostAggregator implements PostAggregatorInterface
7
{
8
    protected string $fieldName;
9
10
    protected string $outputName;
11
12
    protected bool $finalizing;
13
14 50
    public function __construct(string $fieldName, string $outputName, bool $finalizing = false)
15
    {
16 50
        $this->fieldName  = $fieldName;
17 50
        $this->outputName = $outputName;
18 50
        $this->finalizing = $finalizing;
19
    }
20
21
    /**
22
     * Return the aggregator as it can be used in a druid query.
23
     *
24
     * @return array<string,string>
25
     */
26 31
    public function toArray(): array
27
    {
28 31
        return [
29 31
            'type'      => ($this->finalizing ? 'finalizingFieldAccess' : 'fieldAccess'),
30 31
            'name'      => $this->outputName,
31 31
            'fieldName' => $this->fieldName,
32 31
        ];
33
    }
34
}