Completed
Pull Request — 2.1 (#15718)
by Alex
17:00
created

LikeConditionBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 33
ccs 0
cts 7
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 12 2
1
<?php
2
/**
3
 * @link http://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license http://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db\oci\conditions;
9
10
use yii\db\ExpressionInterface;
11
12
/**
13
 * {@inheritdoc}
14
 */
15
class LikeConditionBuilder extends \yii\db\conditions\LikeConditionBuilder
16
{
17
    /**
18
     * @inheritdoc
19
     */
20
    protected $escapeCharacter = '!';
21
    /**
22
     * `\` is initialized in [[buildLikeCondition()]] method since
23
     * we need to choose replacement value based on [[\yii\db\Schema::quoteValue()]].
24
     * @inheritdoc
25
     */
26
    protected $escapingReplacements = [
27
        '%' => '!%',
28
        '_' => '!_',
29
        '!' => '!!',
30
    ];
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function build(ExpressionInterface $expression, array &$params = [])
36
    {
37
        if (!isset($this->escapingReplacements['\\'])) {
38
            /*
39
             * Different pdo_oci8 versions may or may not implement PDO::quote(), so
40
             * yii\db\Schema::quoteValue() may or may not quote \.
41
             */
42
            $this->escapingReplacements['\\'] = substr($this->queryBuilder->db->quoteValue('\\'), 1, -1);
43
        }
44
45
        return parent::build($expression, $params);
46
    }
47
}
48