Passed
Pull Request — master (#395)
by Wilmer
04:09 queued 01:23
created

QuoterProvider::ensureColumnName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 11
rs 9.9666
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Tests\Provider;
6
7
final class QuoterProvider
8
{
9
    /**
10
     * @return string[][]
11
     */
12
    public function columnName(): array
13
    {
14
        return [
15
            ['column', 'column'],
16
            ['`column`', '`column`'],
17
            ['[[column]]', '[[column]]'],
18
            ['{{column}}', '{{column}}'],
19
        ];
20
    }
21
22
    /**
23
     * @return string[][]
24
     */
25
    public function ensureColumnName(): array
26
    {
27
        return [
28
            ['*', '*'],
29
            ['`*`', '`*`'],
30
            ['[[*]]', '[*]'],
31
            ['{{*}}', '{*}'],
32
            ['table.column', 'column'],
33
            ['`table`.`column`', '`column`'],
34
            ['[[table]].[[column]]', 'column'],
35
            ['{{table}}.{{column}}', '{column}'],
36
        ];
37
    }
38
39
    /**
40
     * @return string[][]
41
     */
42
    public function ensureNameQuoted(): array
43
    {
44
        return [
45
            ['name', '{name}'],
46
            ['`name`', '{name}'],
47
            ['[[name]]', '{name}'],
48
            ['{{name}}', '{name}'],
49
            ['table.name', '{table.name}'],
50
            ['`table`.`name`', '{table.name}'],
51
            ['[[table]].[[name]]', '{table.name}'],
52
            ['{{table}}.{{name}}', '{table}.{name}'],
53
        ];
54
    }
55
56
    /**
57
     * @return string[][]
58
     */
59
    public function simpleColumnName(): array
60
    {
61
        return [
62
            ['column', 'column'],
63
            ['`column`', '`column`'],
64
            ['[[column]]', '[[column]]'],
65
            ['{{column}}', '{{column}}'],
66
        ];
67
    }
68
69
    /**
70
     * @return string[][]
71
     */
72
    public function simpleTableName(): array
73
    {
74
        return [
75
            ['table', 'table'],
76
            ['`table`', '`table`'],
77
            ['[[table]]', '[[table]]'],
78
            ['{{table}}', '{{table}}'],
79
        ];
80
    }
81
82
    /**
83
     * @return string[][]
84
     */
85
    public function tableName(): array
86
    {
87
        return [
88
            ['table', 'table'],
89
            ['`table`', '`table`'],
90
            ['(table)', '(table)'],
91
            ['[[table]]', '[[table]]'],
92
            ['{{table}}', '{{table}}'],
93
        ];
94
    }
95
96
    /**
97
     * @return string[][]
98
     */
99
    public function tableNameParts(): array
100
    {
101
        return [
102
            ['`schema`.`table`', ['schema', 'table']],
103
        ];
104
    }
105
106
    /**
107
     * @return string[][]
108
     */
109
    public function unquoteSimpleColumnName(): array
110
    {
111
        return [
112
            ['`column`', 'column'],
113
            ['[[column]]', '[column]'],
114
            ['{{column}}', '{column}'],
115
        ];
116
    }
117
118
    /**
119
     * @return string[][]
120
     */
121
    public function unquoteSimpleTableName(): array
122
    {
123
        return [
124
            ['`table`', 'table'],
125
            ['[[table]]', '[table]'],
126
            ['{{table}}', '{table}'],
127
        ];
128
    }
129
}
130