Conditions | 12 |
Paths | 12 |
Total Lines | 27 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Tests | 24 |
CRAP Score | 12 |
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 |
||
53 | 11 | private function pushResponseToBuffer(string $request): void |
|
54 | { |
||
55 | 11 | $command = explode(' ', strtoupper(trim($request))); |
|
56 | 11 | switch ($command[0]) { |
|
57 | 11 | case 'AUTH': |
|
58 | 10 | case 'HELO': |
|
59 | 9 | case 'EHLO': |
|
60 | 8 | case 'MAIL': |
|
61 | 7 | case 'RCPT': |
|
62 | 6 | case 'RSET': |
|
63 | 5 | case 'NOOP': |
|
64 | 4 | case '.': |
|
65 | 7 | $this->receive = '250 Ok'; |
|
66 | 7 | break; |
|
67 | 4 | case 'DATA': |
|
68 | 1 | $this->receive = '354 End data with <CR><LF>.<CR><LF>'; |
|
69 | 1 | break; |
|
70 | 3 | case 'QUIT': |
|
71 | 1 | $this->receive = '221 Bye'; |
|
72 | 1 | break; |
|
73 | 2 | case 'VRFY': |
|
74 | 1 | $this->receive = '252 null@null'; |
|
75 | 1 | break; |
|
76 | default: |
||
77 | 1 | $this->receive = ''; |
|
78 | } |
||
79 | 11 | } |
|
80 | } |
||
81 |