Passed
Pull Request — master (#133)
by Wilmer
04:36
created

LikeConditionBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 20
ccs 5
cts 6
cp 0.8333
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEscapeSql() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Sqlite\Builder;
6
7
use Yiisoft\Db\QueryBuilder\Conditions\Builder\LikeConditionBuilder as BaseLikeConditionBuilder;
8
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
9
10
final class LikeConditionBuilder extends BaseLikeConditionBuilder
11
{
12
    private string|null $escapeCharacter = '\\';
13
14 31
    public function __construct(QueryBuilderInterface $queryBuilder)
15
    {
16 31
        parent::__construct($queryBuilder, $this->getEscapeSql());
0 ignored issues
show
Unused Code introduced by
The call to Yiisoft\Db\QueryBuilder\...nBuilder::__construct() has too many arguments starting with $this->getEscapeSql(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        parent::/** @scrutinizer ignore-call */ 
17
                __construct($queryBuilder, $this->getEscapeSql());

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.

Loading history...
17
    }
18
19
    /**
20
     * @return string character used to escape special characters in LIKE conditions.
21
     * By default, it's assumed to be `\`.
22
     */
23 31
    private function getEscapeSql(): string
24
    {
25 31
        if ($this->escapeCharacter !== null) {
26 31
            return " ESCAPE '{$this->escapeCharacter}'";
27
        }
28
29
        return '';
30
    }
31
}
32