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