Test Failed
Pull Request — dev (#48)
by Wilmer
25:37 queued 08:28
created

LikeConditionBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Oracle\Builder;
6
7
use Yiisoft\Db\Exception\Exception;
8
use Yiisoft\Db\Expression\ExpressionInterface;
9
use Yiisoft\Db\Query\Conditions\Builder\LikeConditionBuilder as AbstractLikeConditionBuilder;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Db\Query\Conditi...er\LikeConditionBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Yiisoft\Db\Query\QueryBuilderInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Db\Query\QueryBuilderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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