Quoter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 7
c 4
b 0
f 0
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A quoteValue() 0 11 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
9
use function is_string;
10
use function str_replace;
11
12
/**
13
 * Implements MySQL, MariaDB quoting and unquoting methods.
14
 */
15
final class Quoter extends BaseQuoter
16
{
17 19
    public function quoteValue(mixed $value): mixed
18
    {
19 19
        if (!is_string($value)) {
20 1
            return $value;
21
        }
22
23 19
        return "'" . str_replace(
24 19
            ['\\', "\x00", "\n", "\r", "'", '"', "\x1a"],
25 19
            ['\\\\', '\\0', '\\n', '\\r', "\'", '\"', '\\Z'],
26 19
            $value
27 19
        ) . "'";
28
    }
29
}
30