| Conditions | 7 |
| Paths | 2 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 20 |
| CRAP Score | 7.0368 |
| Changes | 0 | ||
| 1 | <?php |
||
| 45 | 15 | public function filter($query, $key, $value) |
|
| 46 | { |
||
| 47 | 15 | if ($key === $this->nameSearchable) { |
|
| 48 | 3 | $fieldsSearchable = $this->searchables; |
|
| 49 | 3 | $query = $query->where(function ($query) use ($fieldsSearchable, $value) { |
|
|
|
|||
| 50 | 3 | foreach ($fieldsSearchable as $field => $condition) { |
|
| 51 | 3 | if (is_numeric($field)) { |
|
| 52 | 3 | $field = $condition; |
|
| 53 | 3 | $condition = "="; |
|
| 54 | 3 | } |
|
| 55 | |||
| 56 | 3 | $condition = trim(strtolower($condition)); |
|
| 57 | |||
| 58 | 3 | if (!empty($value)) { |
|
| 59 | 2 | $search = in_array($condition, ["like", "ilike"]) ? "%{$value}%" : $value; |
|
| 60 | 2 | if ($field == 'id') { |
|
| 61 | $search = intval($search); |
||
| 62 | } |
||
| 63 | 2 | $query->orWhere($this->table.'.'.$field, $condition, $search); |
|
| 64 | 2 | } |
|
| 65 | 3 | } |
|
| 66 | 3 | return $query; |
|
| 67 | 3 | }); |
|
| 68 | |||
| 69 | 3 | return true; |
|
| 70 | } |
||
| 71 | |||
| 72 | 13 | return false; |
|
| 73 | } |
||
| 74 | } |
||
| 75 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.