Conditions | 10 |
Paths | 40 |
Total Lines | 38 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
33 | private function TL($a) |
||
34 | { |
||
35 | $tkk = $this->TKK(); |
||
36 | $b = $tkk[0]; |
||
37 | |||
38 | for ($d = [], $e = 0, $f = 0; $f < $this->JS_length($a); $f++) { |
||
39 | $g = $this->JS_charCodeAt($a, $f); |
||
40 | if (128 > $g) { |
||
41 | $d[$e++] = $g; |
||
42 | } else { |
||
43 | if (2048 > $g) { |
||
44 | $d[$e++] = $g >> 6 | 192; |
||
45 | } else { |
||
46 | if (55296 == ($g & 64512) && $f + 1 < $this->JS_length($a) && 56320 == ($this->JS_charCodeAt($a, $f + 1) & 64512)) { |
||
47 | $g = 65536 + (($g & 1023) << 10) + ($this->JS_charCodeAt($a, ++$f) & 1023); |
||
48 | $d[$e++] = $g >> 18 | 240; |
||
49 | $d[$e++] = $g >> 12 & 63 | 128; |
||
50 | } else { |
||
51 | $d[$e++] = $g >> 12 | 224; |
||
52 | } |
||
53 | $d[$e++] = $g >> 6 & 63 | 128; |
||
54 | } |
||
55 | $d[$e++] = $g & 63 | 128; |
||
56 | } |
||
57 | } |
||
58 | $a = $b; |
||
59 | for ($e = 0; $e < count($d); $e++) { |
||
|
|||
60 | $a += $d[$e]; |
||
61 | $a = $this->RL($a, '+-a^+6'); |
||
62 | } |
||
63 | $a = $this->RL($a, '+-3^+b+-f'); |
||
64 | $a ^= $tkk[1] ? $tkk[1] + 0 : 0; |
||
65 | if (0 > $a) { |
||
66 | $a = ($a & 2147483647) + 2147483648; |
||
67 | } |
||
68 | $a = fmod($a, pow(10, 6)); |
||
69 | |||
70 | return $a.'.'.($a ^ $b); |
||
71 | } |
||
166 |
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: