SketchSummaryPostAggregator::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
c 2
b 0
f 0
cc 1
nc 1
nop 0
crap 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
}