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

FilterClosure   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 9 3
1
<?php
2
namespace NwLaravel\Repositories\Criterias\Filters;
3
4
class FilterClosure implements FilterInterface
5
{
6
    /**
7
     * Filter
8
     *
9
     * @param Query\Builder $query
10
     * @param int|string $key
11
     * @param mixed      $value
12
     *
13
     * @return boolean
14
     */
15 14
    public function filter($query, $key, $value)
16
    {
17 14
        if (is_int($key) && $value instanceof \Closure) {
18 2
            $query = $query->where($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...
19 2
            return true;
20
        }
21
22 13
        return false;
23
    }
24
}
25