Conditions | 6 |
Paths | 4 |
Total Lines | 34 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 10.5 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | 17 | public static function fold($string) |
|
29 | { |
||
30 | 17 | $lines = []; |
|
31 | |||
32 | 17 | if (function_exists('mb_strcut')) { |
|
33 | 17 | while (strlen($string) > 0) { |
|
34 | 17 | 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 | 17 | $lines[] = $string; |
|
39 | 17 | $string = ''; |
|
|
|||
40 | 17 | 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 | 17 | 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
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.