| Conditions | 6 |
| Paths | 4 |
| Total Lines | 34 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 6 |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | public static function fold($string) |
||
| 29 | 4 | { |
|
| 30 | 4 | $lines = array(); |
|
| 31 | |||
| 32 | 4 | if (function_exists('mb_strcut')) { |
|
| 33 | 4 | while (strlen($string) > 0) { |
|
| 34 | 4 | if (strlen($string) > 75) { |
|
| 35 | 4 | $lines[] = mb_strcut($string, 0, 75, 'utf-8'); |
|
| 36 | 4 | $string = ' ' . mb_strcut($string, 75, strlen($string), 'utf-8'); |
|
| 37 | 4 | } else { |
|
| 38 | 1 | $lines[] = $string; |
|
| 39 | 1 | $string = ''; |
|
|
|
|||
| 40 | 1 | break; |
|
| 41 | 4 | } |
|
| 42 | } |
||
| 43 | 4 | } else { |
|
| 44 | 4 | $array = preg_split('/(?<!^)(?!$)/u', $string); |
|
| 45 | $line = ''; |
||
| 46 | 4 | $lineNo = 0; |
|
| 47 | foreach ($array as $char) { |
||
| 48 | $charLen = strlen($char); |
||
| 49 | $lineLen = strlen($line); |
||
| 50 | if ($lineLen + $charLen > 75) { |
||
| 51 | $line = ' ' . $char; |
||
| 52 | ++$lineNo; |
||
| 53 | } else { |
||
| 54 | $line .= $char; |
||
| 55 | } |
||
| 56 | $lines[$lineNo] = $line; |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | return $lines; |
||
| 61 | } |
||
| 62 | } |
||
| 63 |
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.