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

Quoter::quoteValue()   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 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
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\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