Total Complexity | 3 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | use function substr; |
||
14 | |||
15 | final class LikeConditionBuilder extends AbstractLikeConditionBuilder |
||
16 | { |
||
17 | protected ?string $escapeCharacter = '!'; |
||
18 | |||
19 | /** |
||
20 | * `\` is initialized in {@see buildLikeCondition()} method since we need to choose replacement value based on |
||
21 | * {@see Quoter::quoteValue()}. |
||
22 | */ |
||
23 | protected array $escapingReplacements = [ |
||
24 | '%' => '!%', |
||
25 | '_' => '!_', |
||
26 | '!' => '!!', |
||
27 | 31 | ]; |
|
28 | |||
29 | 31 | public function __construct(private QueryBuilderInterface $queryBuilder) |
|
30 | { |
||
31 | parent::__construct($queryBuilder); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | 31 | * @throws Exception |
|
36 | */ |
||
37 | 31 | public function build(LikeConditionInterface $expression, array &$params = []): string |
|
38 | { |
||
39 | if (!isset($this->escapingReplacements['\\'])) { |
||
40 | /* |
||
41 | * Different pdo_oci8 versions may or may not implement PDO::quote(), so {@see Quoter::quoteValue()} may or |
||
42 | 31 | * may not quote \. |
|
43 | */ |
||
44 | $this->escapingReplacements['\\'] = substr((string) $this->queryBuilder->quoter()->quoteValue('\\'), 1, -1); |
||
45 | 31 | } |
|
46 | |||
50 |