| Conditions | 6 |
| Paths | 10 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 45 | 14 | public function filter($query, $key, $value) |
|
| 46 | { |
||
| 47 | 14 | $table = $this->table; |
|
| 48 | 14 | $column = $key; |
|
| 49 | 14 | if (preg_match('/^([a-zA-Z0-9_\-]+)\.([a-zA-Z0-9_\-]+)/', $key, $matches)) { |
|
| 50 | 11 | $table = $matches[1]; |
|
| 51 | 11 | $column = $matches[2]; |
|
| 52 | 11 | } |
|
| 53 | |||
| 54 | 14 | if (preg_match('/^(.+)(_ini|_fim)$/', $column, $match) && in_array($match[1], $this->columns)) { |
|
| 55 | 5 | $field = $match[1]; |
|
| 56 | 5 | $operator = ($match[2]=='_ini')? '>=' : '<='; |
|
| 57 | 5 | if (in_array($field, $this->dates)) { |
|
| 58 | 2 | $filterDate = new FilterDate($operator); |
|
| 59 | 2 | return $filterDate->filter($query, $table.'.'.$field, $value); |
|
| 60 | } |
||
| 61 | |||
| 62 | 4 | $query = $query->where($table.'.'.$field, $operator, $value); |
|
|
|
|||
| 63 | 4 | return true; |
|
| 64 | } |
||
| 65 | |||
| 66 | 10 | return false; |
|
| 67 | } |
||
| 68 | } |
||
| 69 |
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.