Conditions | 19 |
Paths | 19 |
Total Lines | 32 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 19 |
Changes | 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 |
||
16 | 13 | public static function getObject(Fsp\Answer $answer): AAnswer |
|
17 | { |
||
18 | 13 | switch ($answer->getCommand()) { |
|
19 | case Fsp::CC_VERSION: |
||
20 | 2 | return new Version($answer); |
|
21 | case Fsp::CC_GET_DIR: |
||
22 | 2 | return new GetDir($answer); |
|
23 | case Fsp::CC_GET_FILE: |
||
24 | case Fsp::CC_GRAB_FILE: |
||
25 | 1 | return new GetFile($answer); |
|
26 | case Fsp::CC_UP_LOAD: |
||
27 | 1 | return new Upload($answer); |
|
28 | case Fsp::CC_GET_PRO: |
||
29 | case Fsp::CC_SET_PRO: |
||
30 | case Fsp::CC_MAKE_DIR: |
||
31 | 1 | return new Protection($answer); |
|
32 | case Fsp::CC_STAT: |
||
33 | 1 | return new Stats($answer); |
|
34 | case Fsp::CC_INSTALL: |
||
35 | case Fsp::CC_DEL_FILE: |
||
36 | case Fsp::CC_DEL_DIR: |
||
37 | case Fsp::CC_BYE: |
||
38 | case Fsp::CC_GRAB_DONE: |
||
39 | case Fsp::CC_RENAME: |
||
40 | // case Fsp::CC_CH_PASSW: // undefined |
||
41 | 1 | return new Nothing($answer); |
|
42 | case Fsp::CC_LIMIT: // reserved |
||
43 | case Fsp::CC_TEST: // reserved |
||
44 | 1 | return new Test($answer); |
|
45 | case Fsp::CC_ERR: |
||
46 | default: |
||
47 | 3 | return new Error($answer); |
|
48 | } |
||
51 |