| Conditions | 6 |
| Paths | 4 |
| Total Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 10.5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 18 | public static function fold($string) |
|
| 29 | { |
||
| 30 | 18 | $lines = []; |
|
| 31 | |||
| 32 | 18 | if (function_exists('mb_strcut')) { |
|
| 33 | 18 | while (strlen($string) > 0) { |
|
| 34 | 18 | if (strlen($string) > 75) { |
|
| 35 | 2 | $lines[] = mb_strcut($string, 0, 75, 'utf-8'); |
|
| 36 | 2 | $string = ' ' . mb_strcut($string, 75, strlen($string), 'utf-8'); |
|
| 37 | } else { |
||
| 38 | 18 | $lines[] = $string; |
|
| 39 | 18 | $string = ''; |
|
|
|
|||
| 40 | 18 | break; |
|
| 41 | } |
||
| 42 | } |
||
| 43 | } else { |
||
| 44 | $array = preg_split('/(?<!^)(?!$)/u', $string); |
||
| 45 | $line = ''; |
||
| 46 | $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 | 18 | 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.