Conditions | 11 |
Paths | 11 |
Total Lines | 18 |
Code Lines | 16 |
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 |
||
90 | public static function getOS(): int |
||
91 | { |
||
92 | switch (PHP_OS) { |
||
93 | case 'Unix': |
||
94 | case 'FreeBSD': |
||
95 | case 'NetBSD': |
||
96 | case 'OpenBSD': |
||
97 | case 'Linux': |
||
98 | return self::OS_LINUX; |
||
99 | case 'WINNT': |
||
100 | case 'WIN32': |
||
101 | case 'Windows': |
||
102 | case 'CYGWIN_NT': |
||
103 | return self::OS_WIN; |
||
104 | case 'Darwin': |
||
105 | return self::OS_OSX; |
||
106 | default: |
||
107 | return self::OS_UNKNOWN; |
||
108 | } |
||
111 |