Test Failed
Pull Request — master (#66)
by Wilmer
18:24 queued 07:05
created

Quoter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A quoteColumnName() 0 7 2
A __construct() 0 6 1
A getTableNameParts() 0 11 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mssql;
6
7
use Yiisoft\Db\Schema\Quoter as BaseQuoter;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Db\Schema\Quoter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Yiisoft\Db\Schema\QuoterInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Db\Schema\QuoterInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
final class Quoter extends BaseQuoter implements QuoterInterface
11
{
12
    public function __construct(
13
        private array $columnQuoteCharacter,
14
        private array $tableQuoteCharacter,
15
        private string $tablePrefix = ''
16
    ) {
17
        parent::__construct($columnQuoteCharacter, $tableQuoteCharacter, $tablePrefix);
18
    }
19
20
    public function quoteColumnName(string $name): string
21
    {
22
        if (preg_match('/^\[.*]$/', $name)) {
23
            return $name;
24
        }
25
26
        return parent::quoteColumnName($name);
27
    }
28
29
    protected function getTableNameParts(string $name): array
30
    {
31
        $parts = [$name];
32
33
        preg_match_all('/([^.\[\]]+)|\[([^\[\]]+)]/', $name, $matches);
34
35
        if (isset($matches[0]) && !empty($matches[0])) {
36
            $parts = $matches[0];
37
        }
38
39
        return str_replace(['[', ']'], '', $parts);
40
    }
41
}
42