Completed
Push — master ( a098b4...5a38a9 )
by Renato
05:12
created

FilterExpression::filter()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 2
nop 3
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 3
rs 9.6666
c 0
b 0
f 0
1
<?php
2
namespace NwLaravel\Repositories\Criterias\Filters;
3
4
use Illuminate\Database\Query\Expression;
5
6
class FilterExpression implements FilterInterface
7
{
8
    /**
9
     * Filter
10
     *
11
     * @param Query\Builder $query
12
     * @param int|string $key
13
     * @param mixed      $value
14
     *
15
     * @return boolean
16
     */
17 14
    public function filter($query, $key, $value)
18
    {
19 14
        if (is_int($key) && $value instanceof Expression) {
20 2
            $query = $query->whereRaw($value);
0 ignored issues
show
Unused Code introduced by
$query is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
21 2
            return true;
22
        }
23
24 13
        return false;
25
    }
26
}
27