| Conditions | 5 |
| Paths | 8 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 6.7458 |
| Changes | 0 | ||
| 1 | <?php |
||
| 48 | 3 | public function __toString() |
|
| 49 | { |
||
| 50 | 3 | $conditionSql = []; |
|
| 51 | 3 | foreach ($this->conditions as $cond) { |
|
| 52 | 3 | $conditionSql[] = sprintf('( %s )', (string) $cond); |
|
| 53 | } |
||
| 54 | |||
| 55 | 3 | $sql = ''; |
|
|
|
|||
| 56 | 3 | switch ($this->type) { |
|
| 57 | 3 | case 'AND': |
|
| 58 | 3 | $sql = join($conditionSql, ' AND '); |
|
| 59 | 3 | break; |
|
| 60 | case 'OR': |
||
| 61 | $sql = join($conditionSql, ' OR '); |
||
| 62 | break; |
||
| 63 | case 'NOT': |
||
| 64 | $sql = sprintf('NOT %s', $conditionSql[0]); |
||
| 65 | break; |
||
| 66 | default: |
||
| 67 | throw new QueryException(sprintf("Invalid predicate operator \"%s\"", $this->type)); |
||
| 68 | } |
||
| 69 | 3 | return $sql; |
|
| 70 | } |
||
| 71 | } |
||
| 72 |
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.