These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace NwLaravel\Repositories\Criterias\Filters; |
||
3 | |||
4 | class FilterScope implements FilterInterface |
||
5 | { |
||
6 | /** |
||
7 | * @var Model |
||
8 | */ |
||
9 | protected $model; |
||
10 | |||
11 | /** |
||
12 | * Construct |
||
13 | * |
||
14 | * @param Model $model |
||
15 | */ |
||
16 | 14 | public function __construct($model) |
|
17 | { |
||
18 | 14 | $this->model = $model; |
|
19 | 14 | } |
|
20 | |||
21 | /** |
||
22 | * Filter |
||
23 | * |
||
24 | * @param Query\Builder $query |
||
25 | * @param int|string $key |
||
26 | * @param mixed $value |
||
27 | * |
||
28 | * @return boolean |
||
29 | */ |
||
30 | 14 | public function filter($query, $key, $value) |
|
31 | { |
||
32 | 14 | $methodScope = 'scope' . studly_case($key); |
|
33 | 14 | if (is_object($this->model) && method_exists($this->model, $methodScope)) { |
|
34 | 2 | $methodName = camel_case($key); |
|
35 | 2 | $query = $query->{$methodName}($value); |
|
0 ignored issues
–
show
|
|||
36 | 2 | return true; |
|
37 | } |
||
38 | |||
39 | 13 | return false; |
|
40 | } |
||
41 | } |
||
42 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
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.