Passed
Pull Request — master (#38)
by Teye
06:17
created

QueryDataSource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
c 0
b 0
f 0
dl 0
loc 25
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 5 1
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\DataSources;
5
6
use Level23\Druid\Queries\QueryInterface;
7
8
class QueryDataSource implements DataSourceInterface
9
{
10
    /**
11
     * @var \Level23\Druid\Queries\QueryInterface
12
     */
13
    protected QueryInterface $query;
14
15
    /**
16
     * @param \Level23\Druid\Queries\QueryInterface $query
17
     */
18 2
    public function __construct(QueryInterface $query)
19
    {
20 2
        $this->query = $query;
21
    }
22
23
    /**
24
     * Return the TableDataSource so that it can be used in a druid query.
25
     *
26
     * @return array<string,string|array<string,array<mixed>|int|string>>
27
     */
28 2
    public function toArray(): array
29
    {
30
        return [
31 2
            'type'  => 'query',
32 2
            'query' => $this->query->toArray(),
33
        ];
34
    }
35
}