Passed
Push — master ( 8807b4...37e483 )
by Wilmer
03:08
created

BaseQueryBuilderProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 39
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildFrom() 0 57 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Provider;
6
7
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
8
use Yiisoft\Db\Expression\Expression;
9
use Yiisoft\Db\Tests\Support\DbHelper;
10
11
final class BaseQueryBuilderProvider
12
{
13
    public function buildFrom(ConnectionPDOInterface $db): array
14
    {
15
        return [
16
            [
17
                'table1',
18
                DbHelper::replaceQuotes(
19
                    <<<SQL
20
                    SELECT * FROM [[table1]]
21
                    SQL,
22
                    $db->getname(),
23
                ),
24
            ],
25
            [
26
                ['table1'],
27
                DbHelper::replaceQuotes(
28
                    <<<SQL
29
                    SELECT * FROM [[table1]]
30
                    SQL,
31
                    $db->getname(),
32
                ),
33
            ],
34
            [
35
                new Expression('table2'),
36
                <<<SQL
37
                SELECT * FROM table2
38
                SQL,
39
            ],
40
            [
41
                [new Expression('table2')],
42
                <<<SQL
43
                SELECT * FROM table2
44
                SQL,
45
            ],
46
            [
47
                ['alias' => 'table3'],
48
                DbHelper::replaceQuotes(
49
                    <<<SQL
50
                    SELECT * FROM [[table3]] [[alias]]
51
                    SQL,
52
                    $db->getname(),
53
                ),
54
            ],
55
            [
56
                ['alias' => new Expression('table4')],
57
                <<<SQL
58
                SELECT * FROM table4 [alias]
59
                SQL,
60
            ],
61
            [
62
                ['alias' => new Expression('func(:param1, :param2)', ['param1' => 'A', 'param2' => 'B'])],
63
                DbHelper::replaceQuotes(
64
                    <<<SQL
65
                    SELECT * FROM func(:param1, :param2) [[alias]]
66
                    SQL,
67
                    $db->getname(),
68
                ),
69
                ['param1' => 'A', 'param2' => 'B'],
70
            ],
71
        ];
72
    }
73
}
74