Passed
Push — master ( 1f4c93...dcd4be )
by Alexander
13:16 queued 10:08
created

Quoter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 3
b 0
f 0
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A quoteValue() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Mysql;
6
7
use Yiisoft\Db\Schema\Quoter as BaseQuoter;
8
use Yiisoft\Db\Schema\QuoterInterface;
9
10
final class Quoter extends BaseQuoter implements QuoterInterface
11
{
12
    /**
13
     * @psalm-param string[]|string $columnQuoteCharacter
14
     * @psalm-param string[]|string $tableQuoteCharacter
15
     */
16 373
    public function __construct(
17
        array|string $columnQuoteCharacter,
18
        array|string $tableQuoteCharacter,
19
        string $tablePrefix = ''
20
    ) {
21 373
        parent::__construct($columnQuoteCharacter, $tableQuoteCharacter, $tablePrefix);
22
    }
23
24 146
    public function quoteValue(mixed $value): mixed
25
    {
26 146
        if (!is_string($value)) {
27 1
            return $value;
28
        }
29
30 146
        return "'" . preg_replace('~[\x00\x0A\x0D\x1A\x22\x25\x27\x5C\x5F]~u', '\\\$0', $value) . "'";
31
    }
32
}
33