Passed
Push — master ( dea409...00bef5 )
by Jonas
11:45
created

MySqlGrammar   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 35
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A compileInsertUsing() 0 5 1
A compileCycle() 0 9 2
1
<?php
2
3
namespace Staudenmeir\LaravelCte\Query\Grammars;
4
5
use Illuminate\Database\Query\Builder;
6
use Illuminate\Database\Query\Grammars\MySqlGrammar as Base;
7
8
class MySqlGrammar 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\Query\Grammars\MySqlGrammar: $unionExpressions, $expressions, $recursionLimit, $unionRecursionLimit
Loading history...
11
12
    /**
13
     * Compile the cycle detection.
14
     *
15
     * @param \Illuminate\Database\Query\Builder $query
16
     * @param array $expression
17
     * @return string
18
     */
19 29
    public function compileCycle(Builder $query, array $expression)
0 ignored issues
show
Unused Code introduced by
The parameter $query 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

19
    public function compileCycle(/** @scrutinizer ignore-unused */ Builder $query, array $expression)

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...
20
    {
21 29
        if (!$expression['cycle']) {
22 28
            return '';
23
        }
24
25 1
        $columns = $this->columnize($expression['cycle']['columns']);
26
27 1
        return " cycle $columns restrict";
28
    }
29
30
    /**
31
     * Compile an insert statement using a subquery into SQL.
32
     *
33
     * @param \Illuminate\Database\Query\Builder $query
34
     * @param array $columns
35
     * @param string $sql
36
     * @return string
37
     */
38 2
    public function compileInsertUsing(Builder $query, array $columns, string $sql)
39
    {
40 2
        $insert = "insert into {$this->wrapTable($query->from)} ({$this->columnize($columns)}) ";
41
42 2
        return $insert.$this->compileExpressions($query, $query->expressions).' '.$sql;
43
    }
44
}
45