| Conditions | 2 |
| Paths | 2 |
| Total Lines | 55 |
| Code Lines | 49 |
| 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 |
||
| 60 | function setChacha($url ){ |
||
| 61 | $url = strtolower($url); |
||
| 62 | $arr = array( |
||
| 63 | 'a' => array('a','A','a','A','Α','А','α'), |
||
| 64 | 'b' => array('b','B','b','B','Β','В','Ь'), |
||
| 65 | 'c' => array('c','C','c','C','С','с'), |
||
| 66 | 'd' => array('d','D','d','D'), |
||
| 67 | 'e' => array('e','E','e','E','Ε','Е','е'), |
||
| 68 | 'f' => array('f','F','f','F'), |
||
| 69 | 'g' => array('g','G','g','G'), |
||
| 70 | 'h' => array('h','H','h','H','Η','Н','н'), |
||
| 71 | 'i' => array('i','I','i','I','Ι','Ⅰ'), |
||
| 72 | 'j' => array('j','J','j','J'), |
||
| 73 | 'k' => array('k','K','k','K','Κ','κ','к','К'), |
||
| 74 | 'l' => array('l','L','l','L','︱','︳','|'), |
||
| 75 | 'm' => array('m','M','m','M','Μ','М','м'), |
||
| 76 | 'n' => array('n','N','n','N','Ν','∩'), |
||
| 77 | 'o' => array('o','O','o','O','Ο','О'), |
||
| 78 | 'p' => array('p','P','p','P','Ρ','Р','р'), |
||
| 79 | 'q' => array('q','Q','q','Q'), |
||
| 80 | 'r' => array('r','R','r','R'), |
||
| 81 | 's' => array('s','S','s','S'), |
||
| 82 | 't' => array('t','T','t','T','Τ','Т','ㄒ'), |
||
| 83 | 'u' => array('u','U','u','U','∪'), |
||
| 84 | 'v' => array('v','V','v','V','∨','ν'), |
||
| 85 | 'w' => array('w','W','w','W'), |
||
| 86 | 'x' => array('x','X','x','X','Χ','χ','Х','х','Ⅹ','×'), |
||
| 87 | 'y' => array('y','Y','y','Y','У'), |
||
| 88 | 'z' => array('z','Z','z','Z','Ζ'), |
||
| 89 | |||
| 90 | '1' => array('1','1'), |
||
| 91 | '2' => array('2','2'), |
||
| 92 | '3' => array('3','3'), |
||
| 93 | '4' => array('4','4'), |
||
| 94 | '5' => array('5','5'), |
||
| 95 | '6' => array('6','6'), |
||
| 96 | '7' => array('7','7'), |
||
| 97 | '8' => array('8','8'), |
||
| 98 | '9' => array('9','9'), |
||
| 99 | '0' => array('0','0'), |
||
| 100 | |||
| 101 | ':' => array(':',':','∶'), |
||
| 102 | '/' => array('/','/'), |
||
| 103 | '.' => array('。','·','.','、','﹒',',','丶') |
||
| 104 | |||
| 105 | ); |
||
| 106 | $len = strlen( $url ); |
||
| 107 | $temp = "\n\n"; |
||
| 108 | for( $i=0; $i<$len; $i++){ |
||
| 109 | $t_str = substr( $url, $i, 1 ); |
||
| 110 | $sj = mt_rand( 0, count($arr[$t_str])-1 ); |
||
| 111 | $temp .= $arr[$t_str][$sj]; |
||
| 112 | } |
||
| 113 | return $temp; |
||
| 114 | } |
||
| 115 | |||
| 181 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.