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