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

Quoter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 3
dl 0
loc 6
ccs 2
cts 2
cp 1
crap 1
rs 10
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