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

SQLiteGrammar   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A compileUnion() 0 12 6
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