Passed
Push — master ( 37e483...d2fc64 )
by Wilmer
11:53 queued 09:06
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
            ['test', '[test]'],
16
            ['[test]', '[test]'],
17
            ['*', '*'],
18
        ];
19
    }
20
21
    /**
22
     * @return string[][]
23
     */
24
    public function ensureColumnName(): array
25
    {
26
        return [
27
            ['*', '*'],
28
            ['`*`', '`*`'],
29
            ['[[*]]', '[[*]]'],
30
            ['{{*}}', '{{*}}'],
31
            ['table.column', 'column'],
32
            ['`table`.`column`', '`column`'],
33
            ['[[table]].[[column]]', 'column'],
34
            ['{{table}}.{{column}}', '{{column}}'],
35
        ];
36
    }
37
38
    /**
39
     * @return string[][]
40
     */
41
    public function ensureNameQuoted(): array
42
    {
43
        return [
44
            ['name', '{{name}}'],
45
            ['`name`', '{{name}}'],
46
            ['[[name]]', '{{name}}'],
47
            ['{{name}}', '{{name}}'],
48
            ['table.name', '{{table.name}}'],
49
            ['`table`.`name`', '{{table.name}}'],
50
            ['[[table]].[[name]]', '{{table.name}}'],
51
            ['{{table}}.{{name}}', '{{table}}.{{name}}'],
52
        ];
53
    }
54
55
    /**
56
     * @return string[][]
57
     */
58
    public function simpleTableName(): array
59
    {
60
        return [
61
            ['test', '[test]', ],
62
            ['te`st', '[te`st]', ],
63
            ['te\'st', '[te\'st]', ],
64
            ['te"st', '[te"st]', ],
65
            ['current-table-name', '[current-table-name]'],
66
            ['[current-table-name]', '[current-table-name]'],
67
        ];
68
    }
69
70
    /**
71
     * @return string[][]
72
     */
73
    public function tableName(): array
74
    {
75
        return [
76
            ['test', '[test]'],
77
            ['test.test', '[test].[test]'],
78
            ['[test]', '[test]'],
79
            ['[test].[test]', '[test].[test]'],
80
        ];
81
    }
82
83
    /**
84
     * @return string[][]
85
     */
86
    public function tableNameParts(): array
87
    {
88
        return [
89
            ['animal', 'animal',],
90
            ['dbo.animal', 'animal', 'dbo'],
91
            ['[dbo].[animal]', 'animal', 'dbo'],
92
            ['[other].[animal2]', 'animal2', 'other'],
93
            ['other.[animal2]', 'animal2', 'other'],
94
            ['other.animal2', 'animal2', 'other'],
95
        ];
96
    }
97
98
    /**
99
     * @return string[][]
100
     */
101
    public function unquoteSimpleColumnName(): array
102
    {
103
        return [
104
            ['test', 'test'],
105
            ['[test]', 'test'],
106
            ['*', '*'],
107
        ];
108
    }
109
110
    /**
111
     * @return string[][]
112
     */
113
    public function unquoteSimpleTableName(): array
114
    {
115
        return [
116
            ['[test]', 'test'],
117
            ['[te`st]', 'te`st'],
118
            ['[te\'st]', 'te\'st'],
119
            ['[te"st]', 'te"st'],
120
            ['[current-table-name]', 'current-table-name'],
121
            ['[current-table-name]', 'current-table-name'],
122
        ];
123
    }
124
}
125