SegmentMetadataQuery   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
dl 0
loc 36
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parseResponse() 0 3 1
A __construct() 0 4 1
A toArray() 0 6 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
}