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

LikeConditionBuilder::build()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 6
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