Passed
Push — master ( 00bef5...064b0e )
by Jonas
02:59
created

compileTableExpression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Staudenmeir\LaravelCte\Query\Grammars\Traits;
4
5
use Illuminate\Database\Query\Builder;
6
7
trait CompilesSqlServerExpressions
8
{
9
    use CompilesExpressions {
10
        compileSelect as compileSelectParent;
11
    }
12
13
    /**
14
     * Compile a select query into SQL.
15
     *
16
     * @param \Illuminate\Database\Query\Builder $query
17
     * @return string
18
     */
19 46
    public function compileSelect(Builder $query)
20
    {
21 46
        if (!$query->offset) {
22 46
            return $this->compileSelectParent($query);
23
        }
24
25 5
        if (is_null($query->columns)) {
0 ignored issues
show
introduced by
The condition is_null($query->columns) is always false.
Loading history...
26 5
            $query->columns = ['*'];
27
        }
28
29 5
        $expressions = $query->expressions;
0 ignored issues
show
Bug introduced by
The property expressions does not seem to exist on Illuminate\Database\Query\Builder.
Loading history...
30
31 5
        $query->expressions = [];
32
33 5
        $components = $this->compileComponents($query);
0 ignored issues
show
Bug introduced by
It seems like compileComponents() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

33
        /** @scrutinizer ignore-call */ 
34
        $components = $this->compileComponents($query);
Loading history...
34
35 5
        $query->expressions = $expressions;
36
37 5
        return $this->compileAnsiOffset($query, $components);
0 ignored issues
show
Bug introduced by
It seems like compileAnsiOffset() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

37
        return $this->/** @scrutinizer ignore-call */ compileAnsiOffset($query, $components);
Loading history...
38
    }
39
40
    /**
41
     * Compile a common table expression for a query.
42
     *
43
     * @param string $sql
44
     * @param \Illuminate\Database\Query\Builder $query
45
     * @return string
46
     */
47 5
    protected function compileTableExpression($sql, $query)
48
    {
49 5
        return $this->compileExpressions($query, $query->expressions).' '.parent::compileTableExpression($sql, $query);
0 ignored issues
show
Bug introduced by
The property expressions does not seem to exist on Illuminate\Database\Query\Builder.
Loading history...
50
    }
51
52
    /**
53
     * Get the "recursive" keyword.
54
     *
55
     * @param array $expressions
56
     * @return string
57
     */
58 36
    protected function recursiveKeyword(array $expressions)
0 ignored issues
show
Unused Code introduced by
The parameter $expressions is not used and could be removed. ( Ignorable by Annotation )

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

58
    protected function recursiveKeyword(/** @scrutinizer ignore-unused */ array $expressions)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60 36
        return '';
61
    }
62
}
63