Passed
Pull Request — master (#38)
by Teye
05:43
created

JoinDataSource::toArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 9
ccs 7
cts 7
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\DataSources;
5
6
use Level23\Druid\Types\JoinType;
0 ignored issues
show
Bug introduced by
The type Level23\Druid\Types\JoinType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class JoinDataSource implements DataSourceInterface
9
{
10
    protected DataSourceInterface $left;
11
12
    protected DataSourceInterface $right;
13
14
    protected string $rightPrefix;
15
16
    protected string $condition;
17
18
    protected string $joinType;
19
20
    /**
21
     * @param \Level23\Druid\DataSources\DataSourceInterface $left
22
     * @param \Level23\Druid\DataSources\DataSourceInterface $right
23
     * @param string                                         $rightPrefix
24
     * @param string                                         $condition
25
     * @param string                                         $joinType
26
     */
27 4
    public function __construct(
28
        DataSourceInterface $left,
29
        DataSourceInterface $right,
30
        string $rightPrefix,
31
        string $condition,
32
        string $joinType
33
    ) {
34 4
        $this->left        = $left;
35 4
        $this->right       = $right;
36 4
        $this->rightPrefix = $rightPrefix;
37 4
        $this->condition   = $condition;
38 4
        $this->joinType    = JoinType::validate($joinType);
39
    }
40
41
    /**
42
     * Return the TableDataSource so that it can be used in a druid query.
43
     *
44
     * @return array<string,string|array<string,string|string[]|array<mixed>>>
45
     */
46 3
    public function toArray(): array
47
    {
48
        return [
49 3
            'type'        => 'join',
50 3
            'left'        => $this->left->toArray(),
51 3
            'right'       => $this->right->toArray(),
52 3
            'rightPrefix' => $this->rightPrefix,
53 3
            'condition'   => $this->condition,
54 3
            'joinType'    => $this->joinType,
55
        ];
56
    }
57
}