Total Complexity | 5 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 90% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class LikeConditionBuilder extends AbstractLikeConditionBuilder |
||
16 | { |
||
17 | private string|null $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 | ]; |
||
28 | |||
29 | 31 | public function __construct(private QueryBuilderInterface $queryBuilder) |
|
30 | { |
||
31 | 31 | parent::__construct($queryBuilder, $this->getEscapeSql()); |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * @throws Exception |
||
36 | */ |
||
37 | 31 | public function build(LikeConditionInterface $expression, array &$params = []): string |
|
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return string character used to escape special characters in LIKE conditions. |
||
52 | * By default, it's assumed to be `!`. |
||
53 | */ |
||
54 | 31 | private function getEscapeSql(): string |
|
61 | } |
||
62 | } |
||
63 |