Passed
Push — master ( e1711c...6da277 )
by Jonas
04:38
created

SQLiteGrammar::compileUnion()   A

Complexity

Conditions 6
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 6

Importance

Changes 0
Metric Value
cc 6
eloc 6
nc 3
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 6
rs 9.2222
c 0
b 0
f 0
1
<?php
2
3
namespace Staudenmeir\LaravelCte\Query\Grammars;
4
5
use Illuminate\Database\Query\Grammars\SQLiteGrammar as Base;
6
use Staudenmeir\LaravelCte\Query\Builder;
7
8
class SQLiteGrammar extends Base
9
{
10
    use CompilesExpressions;
0 ignored issues
show
introduced by
The trait Staudenmeir\LaravelCte\Q...ars\CompilesExpressions requires some properties which are not provided by Staudenmeir\LaravelCte\Q...\Grammars\SQLiteGrammar: $expressions, $recursionLimit
Loading history...
11
12
    /**
13
     * Compile a single union statement.
14
     *
15
     * @param array $union
16
     * @return string
17
     */
18 9
    protected function compileUnion(array $union)
19
    {
20 9
        $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 8);
21
22 9
        if (($backtrace[6]['class'] === Builder::class && $backtrace[6]['function'] === 'withExpression')
23 9
            || ($backtrace[7]['class'] === Builder::class && $backtrace[7]['function'] === 'withExpression')) {
24 5
            $conjunction = $union['all'] ? ' union all ' : ' union ';
25
26 5
            return $conjunction.$union['query']->toSql();
27
        }
28
29 4
        return parent::compileUnion($union);
30
    }
31
}
32