Passed
Push — master ( fa28a2...7ee344 )
by Wilmer
33:24 queued 29:54
created

Quoter::quoteColumnName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql;
6
7
use Yiisoft\Db\Schema\Quoter as BaseQuoter;
8
9
use function preg_match;
10
use function preg_match_all;
11
12
final class Quoter extends BaseQuoter
13
{
14 282
    public function quoteColumnName(string $name): string
15
    {
16 282
        if (preg_match('/^\[.*]$/', $name)) {
17 31
            return $name;
18
        }
19
20 280
        return parent::quoteColumnName($name);
21
    }
22
23 244
    public function getTableNameParts(string $name): array
24
    {
25 244
        if (preg_match_all('/([^.\[\]]+)|\[([^\[\]]+)]/', $name, $matches)) {
26 242
            $parts = array_slice($matches[0], -4, 4);
27
        } else {
28 2
            $parts = [$name];
29
        }
30
31 244
        return array_map(fn ($part) => $this->unquoteSimpleTableName($part), $parts);
32
    }
33
}
34