Failed Conditions
Push — master ( 389cea...9cc91e )
by Adrien
13:06
created

MariaDbQuotingConnection   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 3
c 1
b 0
f 0
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A quote() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EcodevTests\Felix\Traits;
6
7
use Doctrine\DBAL\Connection;
8
use Doctrine\DBAL\ParameterType;
9
use Doctrine\DBAL\Types\Type;
10
11
class MariaDbQuotingConnection extends Connection
12
{
13
    /**
14
     * This replicate MariaDB quoting but without a real connection to DB for ease of testing.
15
     *
16
     * @param null|int|string|Type $type
17
     */
18
    public function quote(mixed $value, $type = ParameterType::STRING)
19
    {
20
        $quoted = "'" . str_replace(["'", "\n"], ["\\'", '\\n'], (string) $value) . "'";
21
22
        return $quoted;
23
    }
24
}
25