Passed
Branch dev (21c681)
by Wilmer
03:59 queued 45s
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 350
    public function __construct(
13
        array|string $columnQuoteCharacter,
14
        array|string $tableQuoteCharacter,
15
        string $tablePrefix = ''
16
    ) {
17 350
        parent::__construct($columnQuoteCharacter, $tableQuoteCharacter, $tablePrefix);
18 350
    }
19
20 136
    public function quoteValue(int|string $value): int|string
21
    {
22 136
        if (!is_string($value)) {
23 1
            return $value;
24
        }
25
26 136
        return "'" . preg_replace('~[\x00\x0A\x0D\x1A\x22\x25\x27\x5C\x5F]~u', '\\\$0', $value) . "'";
27
    }
28
}
29