SketchSummaryPostAggregator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toArray() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\PostAggregations;
5
6
class SketchSummaryPostAggregator implements PostAggregatorInterface
7
{
8
    protected string $outputName;
9
10
    protected PostAggregatorInterface $dimension;
11
12
    /**
13
     * QuantilePostAggregator constructor.
14
     *
15
     * @param PostAggregatorInterface $dimension    Post aggregator that refers to a DoublesSketch (fieldAccess or
16
     *                                              another post aggregator)
17
     * @param string                  $outputName   The name as it will be used in our result.
18
     */
19 1
    public function __construct(PostAggregatorInterface $dimension, string $outputName)
20
    {
21 1
        $this->outputName = $outputName;
22 1
        $this->dimension  = $dimension;
23
    }
24
25
    /**
26
     * Return the aggregator as it can be used in a druid query.
27
     *
28
     * @return array<string,string|array<string,string|array<mixed>>>
29
     */
30 1
    public function toArray(): array
31
    {
32 1
        return [
33 1
            'type'  => 'quantilesDoublesSketchToString',
34 1
            'name'  => $this->outputName,
35 1
            'field' => $this->dimension->toArray(),
36 1
        ];
37
    }
38
}