Passed
Pull Request — master (#12)
by Bas
02:32
created

IntoClause   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 31
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A compile() 0 18 3
A __construct() 0 4 1
1
<?php
2
3
namespace LaravelFreelancerNL\FluentAQL\Clauses;
4
5
use LaravelFreelancerNL\FluentAQL\QueryBuilder;
6
7
class IntoClause extends Clause
8
{
9
10
    protected $groupsVariable;
11
12
    protected $projectionExpression;
13
14 1
    public function __construct($groupsVariable, $projectionExpression = null)
15
    {
16 1
        $this->groupsVariable = $groupsVariable;
17 1
        $this->projectionExpression = $projectionExpression;
18 1
    }
19
20 1
    public function compile(QueryBuilder $queryBuilder): string
21
    {
22 1
        $this->groupsVariable = $queryBuilder->normalizeArgument($this->groupsVariable, 'Variable');
0 ignored issues
show
Bug introduced by
'Variable' of type string is incompatible with the type array|null expected by parameter $allowedExpressionTypes of LaravelFreelancerNL\Flue...er::normalizeArgument(). ( Ignorable by Annotation )

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

22
        $this->groupsVariable = $queryBuilder->normalizeArgument($this->groupsVariable, /** @scrutinizer ignore-type */ 'Variable');
Loading history...
23 1
        $queryBuilder->registerVariable($this->groupsVariable);
0 ignored issues
show
Bug introduced by
$this->groupsVariable of type LaravelFreelancerNL\Flue...\Expressions\Expression is incompatible with the type array|string expected by parameter $variableName of LaravelFreelancerNL\Flue...der::registerVariable(). ( Ignorable by Annotation )

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

23
        $queryBuilder->registerVariable(/** @scrutinizer ignore-type */ $this->groupsVariable);
Loading history...
24
25 1
        if (isset($this->projectionExpression)) {
26 1
            $this->projectionExpression = $queryBuilder->normalizeArgument(
27 1
                $this->projectionExpression,
28 1
                ['Reference', 'Object', 'Function', 'Query', 'Bind']
29
            );
30
        }
31
32 1
        $output = 'INTO ' . $this->groupsVariable->compile($queryBuilder);
33 1
        if (isset($this->projectionExpression)) {
34 1
            $output .= ' = ' . $this->projectionExpression->compile($queryBuilder);
35
        }
36
37 1
        return $output;
38
    }
39
}
40