Passed
Branch dev (21c681)
by Wilmer
03:59 queued 45s
created

Quoter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 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