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

MySqlGrammar::compileCycle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
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