FieldAccessPostAggregator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

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