| Conditions | 8 | 
| Paths | 18 | 
| Total Lines | 70 | 
| Code Lines | 50 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 2 | ||
| Bugs | 0 | Features | 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 | ||
| 144 | public static function kbdSymbol($inputKey, $inputOperatingSystem = "default") | ||
| 145 |     { | ||
| 146 | $inputKey = mb_strtolower($inputKey); | ||
| 147 | |||
| 148 |         if ($inputOperatingSystem == "auto") { | ||
| 149 | |||
| 150 | $inputOperatingSystem = "default"; | ||
| 151 | |||
| 152 | $getClientOperatingSystem = self::getClientOperatingSystem(); | ||
|  | |||
| 153 | |||
| 154 | if ($getClientOperatingSystem == "linux" || | ||
| 155 | $getClientOperatingSystem == "mac" || | ||
| 156 |                 $getClientOperatingSystem == "win") { | ||
| 157 | $inputOperatingSystem = $getClientOperatingSystem; | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | $arrayConvert = array( | ||
| 162 | "return" => "enter", | ||
| 163 | "control" => "ctrl", | ||
| 164 | "escape" => "esc", | ||
| 165 | "caps lock" => "caps-lock", | ||
| 166 | "page up" => "page-up", | ||
| 167 | "page down" => "page-down", | ||
| 168 | "arrow left" => "arrow-left", | ||
| 169 | "left" => "arrow-left", | ||
| 170 | "arrow up" => "arrow-up", | ||
| 171 | "up" => "arrow-up", | ||
| 172 | "arrow right" => "arrow-right", | ||
| 173 | "right" => "arrow-right", | ||
| 174 | "arrow down" => "arrow-down", | ||
| 175 | "down" => "arrow-down" | ||
| 176 | ); | ||
| 177 | |||
| 178 | /* Convert input */ | ||
| 179 |         if (array_key_exists($inputKey, $arrayConvert)) { | ||
| 180 | $inputKey = $arrayConvert[$inputKey]; | ||
| 181 | } | ||
| 182 | |||
| 183 | $arrayKeySymbols = array( | ||
| 184 |         "shift" => array("default" => "⇧"), | ||
| 185 |         "opt" => array("default" => "⌥"), | ||
| 186 |         "enter" => array("default" => "⏎", "mac" => "⌤"), | ||
| 187 |         "alt" => array("default" => "⎇", "mac" => "⌥"), | ||
| 188 |         "delete" => array("default" => "⌫"), | ||
| 189 |         "ctrl" => array("default" => "✲", "win" => "✲", "linux" => "⎈", "mac" => "^"), | ||
| 190 |         "esc" => array("default" => "⎋"), | ||
| 191 |         "command" => array("default" => "⌘"), | ||
| 192 |         "tab" => array("default" => "↹", "mac" => "⇥"), | ||
| 193 |         "caps-lock" => array("default" => "A", "mac" => "⇪"), | ||
| 194 |         "page-up" => array("default" => "▲", "mac" => "⇞"), | ||
| 195 |         "page-down" => array("default" => "▼", "mac" => "⇟"), | ||
| 196 |         "arrow-left" => array("default" => "←"), | ||
| 197 |         "arrow-up" => array("default" => "↑"), | ||
| 198 |         "arrow-right" => array("default" => "→"), | ||
| 199 |         "arrow-down" => array("default" => "↓"), | ||
| 200 | // Sun | ||
| 201 |         "compose" => array("default" => "⎄"), | ||
| 202 |         "meta" => array("default" => "◆") | ||
| 203 | ); | ||
| 204 | |||
| 205 |         if (array_key_exists($inputKey, $arrayKeySymbols)) { | ||
| 206 | |||
| 207 | return ((array_key_exists($inputOperatingSystem, $arrayKeySymbols[$inputKey])) ? | ||
| 208 | $arrayKeySymbols[$inputKey][$inputOperatingSystem] : | ||
| 209 | $arrayKeySymbols[$inputKey]["default"]); | ||
| 210 | } | ||
| 211 | |||
| 212 | return null; | ||
| 213 | } | ||
| 214 | |||
| 253 | 
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.