| Conditions | 5 |
| Paths | 8 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 5.005 |
| Changes | 0 | ||
| 1 | <?php |
||
| 58 | 5 | public function __toString() |
|
| 59 | { |
||
| 60 | 5 | $conditionSql = []; |
|
| 61 | 5 | foreach ($this->conditions as $cond) { |
|
| 62 | 5 | $conditionSql[] = sprintf('( %s )', (string) $cond); |
|
| 63 | } |
||
| 64 | |||
| 65 | 5 | $sql = ''; |
|
|
|
|||
| 66 | 5 | switch ($this->type) { |
|
| 67 | 5 | case 'AND': |
|
| 68 | 3 | $sql = join($conditionSql, ' AND '); |
|
| 69 | 3 | break; |
|
| 70 | 2 | case 'OR': |
|
| 71 | 1 | $sql = join($conditionSql, ' OR '); |
|
| 72 | 1 | break; |
|
| 73 | 1 | case 'NOT': |
|
| 74 | 1 | $sql = sprintf('NOT %s', $conditionSql[0]); |
|
| 75 | 1 | break; |
|
| 76 | default: |
||
| 77 | throw new QueryException(sprintf("Invalid predicate operator \"%s\"", $this->type)); |
||
| 78 | } |
||
| 79 | 5 | return $sql; |
|
| 80 | } |
||
| 81 | } |
||
| 82 |
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.