Conditions | 11 |
Paths | 11 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
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 |
||
30 | public static function create(RequestException $e) { |
||
31 | |||
32 | if($response = $e->getResponse()) { |
||
33 | |||
34 | switch ($response->getStatusCode()) { |
||
35 | case 400: |
||
36 | return new ValidationException($e); |
||
37 | case 401: |
||
38 | return new AuthenticationException($e); |
||
39 | case 403: |
||
40 | return new AccessDeniedException($e); |
||
41 | case 404: |
||
42 | return new NotFoundException($e); |
||
43 | case 405: |
||
44 | return new MethodNotAllowedException($e); |
||
45 | case 406: |
||
46 | return new UnsupportedAcceptHeaderException($e); |
||
47 | case 409: |
||
48 | return new ConflictingStateException($e); |
||
49 | case 415: |
||
50 | return new UnsupportedContentTypeException($e); |
||
51 | case 429: |
||
52 | return new RateLimitExceededException($e); |
||
53 | } |
||
54 | } |
||
55 | |||
56 | return new ApiException($e); |
||
57 | } |
||
58 | |||
91 |