| Total Complexity | 5 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| 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 | public function __construct(private QueryBuilderInterface $queryBuilder) |
||
| 30 | { |
||
| 31 | parent::__construct($queryBuilder, $this->getEscapeSql()); |
||
|
|
|||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @throws Exception |
||
| 36 | */ |
||
| 37 | 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 | private function getEscapeSql(): string |
||
| 63 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.