CdfPostAggregator::toArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 7
ccs 6
cts 6
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 CdfPostAggregator implements PostAggregatorInterface
7
{
8
    protected string $outputName;
9
10
    protected PostAggregatorInterface $dimension;
11
12
    /**
13
     * @var float[]
14
     */
15
    protected array $splitPoints;
16
17
    /**
18
     * QuantilePostAggregator constructor.
19
     *
20
     * @param PostAggregatorInterface $dimension    Post aggregator that refers to a DoublesSketch (fieldAccess or
21
     *                                              another post aggregator)
22
     * @param string                  $outputName   The name as it will be used in our result.
23
     * @param float[]                 $splitPoints  Array of split points
24
     */
25 1
    public function __construct(PostAggregatorInterface $dimension, string $outputName, array $splitPoints)
26
    {
27 1
        $this->outputName  = $outputName;
28 1
        $this->dimension   = $dimension;
29 1
        $this->splitPoints = $splitPoints;
30
    }
31
32
    /**
33
     * Return the aggregator as it can be used in a druid query.
34
     *
35
     * @return array<string,string|float[]|array<string,string|array<mixed>>>
36
     */
37 1
    public function toArray(): array
38
    {
39 1
        return [
40 1
            'type'        => 'quantilesDoublesSketchToCDF',
41 1
            'name'        => $this->outputName,
42 1
            'field'       => $this->dimension->toArray(),
43 1
            'splitPoints' => $this->splitPoints,
44 1
        ];
45
    }
46
}