TimeSeriesQueryResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A data() 0 8 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Responses;
5
6
class TimeSeriesQueryResponse extends QueryResponse
7
{
8
    protected string $timeOutputName;
9
10
    /**
11
     * TimeSeriesQueryResponse constructor.
12
     *
13
     * @param array<string|int,string|int|array<mixed>> $response $response
14
     * @param string                                    $timeOutputName
15
     */
16 5
    public function __construct(array $response, string $timeOutputName)
17
    {
18 5
        parent::__construct($response);
19
20 5
        $this->timeOutputName = $timeOutputName;
21
    }
22
23
    /**
24
     * Return the data in a "normalized" way, so we can easily iterate over it
25
     *
26
     * @return array<array<mixed>>
27
     */
28 2
    public function data(): array
29
    {
30 2
        return array_map(function ($row) {
31
            /** @var array<string,array<array<mixed>>> $row */
32 1
            $row['result'][$this->timeOutputName] = $row['timestamp'];
33
34 1
            return $row['result'];
35 2
        }, $this->response);
36
    }
37
}