QueryExpressionBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 16
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A build() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Query;
6
7
use Yiisoft\Db\Exception\Exception;
8
use Yiisoft\Db\Exception\InvalidArgumentException;
9
use Yiisoft\Db\Exception\InvalidConfigException;
10
use Yiisoft\Db\Exception\NotSupportedException;
11
use Yiisoft\Db\Expression\ExpressionBuilderInterface;
12
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
13
14
/**
15
 * Used internally to build {@see Query} object using unified {@see \Yiisoft\Db\QueryBuilder\AbstractQueryBuilder}
16
 * expression building interface.
17
 */
18
final class QueryExpressionBuilder implements ExpressionBuilderInterface
19
{
20
    public function __construct(private QueryBuilderInterface $queryBuilder)
21
    {
22
    }
23
24
    /**
25
     * @throws Exception
26
     * @throws InvalidArgumentException
27
     * @throws InvalidConfigException
28
     * @throws NotSupportedException
29
     */
30
    public function build(QueryInterface $expression, array &$params = []): string
31
    {
32
        [$sql, $params] = $this->queryBuilder->build($expression, $params);
33 81
        return "($sql)";
34
    }
35
}
36