| Total Complexity | 5 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | final class LikeConditionBuilder extends \Yiisoft\Db\QueryBuilder\Condition\Builder\LikeConditionBuilder |
||
| 18 | { |
||
| 19 | private string $escapeCharacter = '!'; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * `\` is initialized in {@see buildLikeCondition()} method since there is a need to choose replacement value |
||
| 23 | * based on {@see Quoter::quoteValue()}. |
||
| 24 | */ |
||
| 25 | protected array $escapingReplacements = [ |
||
| 26 | '%' => '!%', |
||
| 27 | '_' => '!_', |
||
| 28 | '!' => '!!', |
||
| 29 | ]; |
||
| 30 | |||
| 31 | 33 | public function __construct(private QueryBuilderInterface $queryBuilder) |
|
| 32 | { |
||
| 33 | 33 | parent::__construct($queryBuilder, $this->getEscapeSql()); |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @throws Exception |
||
| 38 | */ |
||
| 39 | 33 | public function build(LikeConditionInterface $expression, array &$params = []): string |
|
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return string Character used to escape special characters in `LIKE` conditions. By default, it's assumed to be |
||
| 54 | * `!`. |
||
| 55 | */ |
||
| 56 | 33 | private function getEscapeSql(): string |
|
| 59 | } |
||
| 60 | } |
||
| 61 |