Passed
Branch master (7be2f8)
by Wilmer
12:18
created

Quoter::getTableNameParts()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
crap 2.0185
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 215
    public function quoteColumnName(string $name): string
15
    {
16 215
        if (preg_match('/^\[.*]$/', $name)) {
17 29
            return $name;
18
        }
19
20 215
        return parent::quoteColumnName($name);
21
    }
22
23 205
    public function getTableNameParts(string $name): array
24
    {
25 205
        if (preg_match_all('/([^.\[\]]+)|\[([^\[\]]+)]/', $name, $matches)) {
26 205
            $parts = array_slice($matches[0], -4, 4);
27
        } else {
28
            $parts = [$name];
29
        }
30
31 205
        return array_map(function ($part) {
32 205
            return $this->unquoteSimpleTableName($part);
33
        }, $parts);
34
    }
35
}
36