| Conditions | 11 |
| Paths | 9 |
| Total Lines | 29 |
| Code Lines | 22 |
| 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 |
||
| 69 | public static function getClientBrowser() |
||
| 70 | { |
||
| 71 | if (getenv('HTTP_USER_AGENT')) { |
||
| 72 | |||
| 73 | $userAgent = getenv('HTTP_USER_AGENT'); |
||
| 74 | |||
| 75 | if (( |
||
| 76 | preg_match('/MSIE/i', $userAgent) || |
||
| 77 | preg_match('/Trident/i', $userAgent) |
||
| 78 | ) && |
||
| 79 | !preg_match('/Opera/i', $userAgent)) { |
||
| 80 | return 'Internet Explorer'; |
||
| 81 | } elseif (preg_match('/Camino/i', $userAgent)) { |
||
| 82 | return "Camino"; |
||
| 83 | } elseif (preg_match('/Firefox/i', $userAgent)) { |
||
| 84 | return "Firefox"; |
||
| 85 | } elseif (preg_match('/Safari/i', $userAgent)) { |
||
| 86 | return "Safari"; |
||
| 87 | } elseif (preg_match('/Chrome/i', $userAgent)) { |
||
| 88 | return "Chrome"; |
||
| 89 | } elseif (preg_match('/Konqueror/i', $userAgent)) { |
||
| 90 | return "Konqueror"; |
||
| 91 | } elseif (preg_match('/Opera/i', $userAgent)) { |
||
| 92 | return "Opera"; |
||
| 93 | } |
||
| 94 | } |
||
| 95 | |||
| 96 | return null; |
||
| 97 | } |
||
| 98 | } |
||
| 99 |