Conditions | 2 |
Paths | 2 |
Total Lines | 15 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 2.0625 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
48 | 4 | public static function swaprandbyte($input) |
|
49 | { |
||
50 | 4 | $len = strlen($input); |
|
|
|||
51 | 4 | $input = str_split($input); |
|
52 | 4 | $offset = rand(0, $len - 1); |
|
53 | 4 | $byte = $input[$offset]; |
|
54 | 4 | $rbyte = \Dcrypt\Random::bytes(1); |
|
55 | 4 | if ($byte === $rbyte) { |
|
56 | $rbyte = (ord($rbyte) + 1) % 256; |
||
57 | $rbyte = chr($rbyte); |
||
58 | } |
||
59 | 4 | $input[$offset] = $rbyte; |
|
60 | |||
61 | 4 | return implode($input); |
|
62 | } |
||
63 | |||
65 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.