| Conditions | 1 |
| Paths | 1 |
| Total Lines | 78 |
| Code Lines | 75 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 39 | function strToASCII($str) |
||
| 40 | { |
||
| 41 | $trans = [ |
||
| 42 | 'Š' => 'S', |
||
| 43 | 'Ș' => 'S', |
||
| 44 | 'š' => 's', |
||
| 45 | 'ș' => 's', |
||
| 46 | 'Ð' => 'Dj', |
||
| 47 | 'Ž' => 'Z', |
||
| 48 | 'ž' => 'z', |
||
| 49 | 'À' => 'A', |
||
| 50 | 'Á' => 'A', |
||
| 51 | 'Â' => 'A', |
||
| 52 | 'Ã' => 'A', |
||
| 53 | 'Ä' => 'A', |
||
| 54 | 'Ă' => 'A', |
||
| 55 | 'Å' => 'A', |
||
| 56 | 'Æ' => 'A', |
||
| 57 | 'Ç' => 'C', |
||
| 58 | 'È' => 'E', |
||
| 59 | 'É' => 'E', |
||
| 60 | 'Ê' => 'E', |
||
| 61 | 'Ë' => 'E', |
||
| 62 | 'Ì' => 'I', |
||
| 63 | 'Í' => 'I', |
||
| 64 | 'Î' => 'I', |
||
| 65 | 'Ï' => 'I', |
||
| 66 | 'Ñ' => 'N', |
||
| 67 | 'Ò' => 'O', |
||
| 68 | 'Ó' => 'O', |
||
| 69 | 'Ô' => 'O', |
||
| 70 | 'Õ' => 'O', |
||
| 71 | 'Ö' => 'O', |
||
| 72 | 'Ø' => 'O', |
||
| 73 | 'Ù' => 'U', |
||
| 74 | 'Ú' => 'U', |
||
| 75 | 'Ț' => 'T', |
||
| 76 | 'Û' => 'U', |
||
| 77 | 'Ü' => 'U', |
||
| 78 | 'Ý' => 'Y', |
||
| 79 | 'Þ' => 'B', |
||
| 80 | 'ß' => 'Ss', |
||
| 81 | 'à' => 'a', |
||
| 82 | 'á' => 'a', |
||
| 83 | 'â' => 'a', |
||
| 84 | 'ã' => 'a', |
||
| 85 | 'ä' => 'a', |
||
| 86 | 'ă' => 'a', |
||
| 87 | 'å' => 'a', |
||
| 88 | 'æ' => 'a', |
||
| 89 | 'ç' => 'c', |
||
| 90 | 'è' => 'e', |
||
| 91 | 'é' => 'e', |
||
| 92 | 'ê' => 'e', |
||
| 93 | 'ë' => 'e', |
||
| 94 | 'ì' => 'i', |
||
| 95 | 'í' => 'i', |
||
| 96 | 'î' => 'i', |
||
| 97 | 'ï' => 'i', |
||
| 98 | 'ð' => 'o', |
||
| 99 | 'ñ' => 'n', |
||
| 100 | 'ò' => 'o', |
||
| 101 | 'ó' => 'o', |
||
| 102 | 'ô' => 'o', |
||
| 103 | 'õ' => 'o', |
||
| 104 | 'ö' => 'o', |
||
| 105 | 'ø' => 'o', |
||
| 106 | 'ù' => 'u', |
||
| 107 | 'ú' => 'u', |
||
| 108 | 'û' => 'u', |
||
| 109 | 'ý' => 'y', |
||
| 110 | 'ý' => 'y', |
||
| 111 | 'þ' => 'b', |
||
| 112 | 'ÿ' => 'y', |
||
| 113 | 'ƒ' => 'f', |
||
| 114 | 'ț' => 't' |
||
| 115 | ]; |
||
| 116 | return strtr($str, $trans); |
||
| 117 | } |
||
| 132 |