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