ExpressionBuilder::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @link https://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license https://www.yiiframework.com/license/
6
 */
7
8
namespace yii\db;
9
10
/**
11
 * Class ExpressionBuilder builds objects of [[yii\db\Expression]] class.
12
 *
13
 * @author Dmitry Naumenko <[email protected]>
14
 * @since 2.0.14
15
 */
16
class ExpressionBuilder implements ExpressionBuilderInterface
17
{
18
    use ExpressionBuilderTrait;
19
20
21
    /**
22
     * {@inheritdoc}
23
     * @param Expression|ExpressionInterface $expression the expression to be built
24
     */
25 389
    public function build(ExpressionInterface $expression, array &$params = [])
26
    {
27 389
        $params = array_merge($params, $expression->params);
0 ignored issues
show
Bug introduced by
Accessing params on the interface yii\db\ExpressionInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
28 389
        return $expression->__toString();
0 ignored issues
show
Bug introduced by
The method __toString() does not exist on yii\db\ExpressionInterface. It seems like you code against a sub-type of yii\db\ExpressionInterface such as yii\db\Query or yii\db\Expression. ( Ignorable by Annotation )

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

28
        return $expression->/** @scrutinizer ignore-call */ __toString();
Loading history...
29
    }
30
}
31