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

InlineDataSource   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 9
c 0
b 0
f 0
dl 0
loc 33
ccs 7
cts 7
cp 1
rs 10

2 Methods

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