Failed Conditions
Push — master ( 5be1f5...5a2c4b )
by Bas
09:45
created

QueryExpression::compile()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 2
nop 1
dl 0
loc 16
ccs 8
cts 8
cp 1
crap 3
rs 10
c 3
b 0
f 0
1
<?php
2
3
namespace LaravelFreelancerNL\FluentAQL\Expressions;
4
5
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
6
7
/**
8
 * Query expression.
9
 */
10
class QueryExpression extends Expression implements ExpressionInterface
11
{
12
    /** @var QueryBuilder */
13
    protected $expression;
14
15 6
    public function __construct(QueryBuilder $expression)
16
    {
17 6
        parent::__construct($expression);
18 6
    }
19
20 6
    public function compile(QueryBuilder $queryBuilder): string
21
    {
22 6
        $this->expression->registerVariable($queryBuilder->getVariables());
23
24 6
        $this->expression = $this->expression->compile($queryBuilder);
0 ignored issues
show
Unused Code introduced by
The call to LaravelFreelancerNL\Flue...QueryBuilder::compile() has too many arguments starting with $queryBuilder. ( Ignorable by Annotation )

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

24
        /** @scrutinizer ignore-call */ 
25
        $this->expression = $this->expression->compile($queryBuilder);

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...
25
26 6
        $queryBuilder->binds = array_unique(array_merge($queryBuilder->binds, $this->expression->binds));
27
28
        // Extract collections
29 6
        if (isset($this->expression->collections)) {
30 6
            foreach ($this->expression->collections as $mode => $collections) {
31 1
                $queryBuilder->registerCollections($this->expression->collections[$mode], $mode);
32
            }
33
        }
34
35 6
        return '(' . $this->expression . ')';
36
    }
37
}
38