SegmentMetadataQuery::parseResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Queries;
5
6
use Level23\Druid\Collections\IntervalCollection;
7
use Level23\Druid\DataSources\DataSourceInterface;
8
use Level23\Druid\Responses\SegmentMetadataQueryResponse;
9
10
class SegmentMetadataQuery implements QueryInterface
11
{
12
    protected DataSourceInterface $dataSource;
13
14
    protected IntervalCollection $intervals;
15
16 1
    public function __construct(DataSourceInterface $dataSource, IntervalCollection $intervals)
17
    {
18 1
        $this->dataSource = $dataSource;
19 1
        $this->intervals  = $intervals;
20
    }
21
22
    /**
23
     * Return the query in array format, so we can fire it to druid.
24
     *
25
     * @return array<string,array<int|string,array<string>|string>|string>
26
     */
27 1
    public function toArray(): array
28
    {
29 1
        return [
30 1
            'queryType'  => 'segmentMetadata',
31 1
            'dataSource' => $this->dataSource->toArray(),
32 1
            'intervals'  => $this->intervals->toArray(),
33 1
        ];
34
    }
35
36
    /**
37
     * Parse the response into something we can return to the user.
38
     *
39
     * @param array<string|int,array<mixed>|int|string> $response
40
     *
41
     * @return SegmentMetadataQueryResponse
42
     */
43 1
    public function parseResponse(array $response): SegmentMetadataQueryResponse
44
    {
45 1
        return new SegmentMetadataQueryResponse($response);
46
    }
47
}