| Conditions | 17 |
| Paths | 17 |
| Total Lines | 36 |
| Code Lines | 34 |
| 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 namespace CalDAVClient\Facade\Requests; |
||
| 50 | public function build($type, $params = []){ |
||
| 51 | switch(strtoupper($type)){ |
||
| 52 | case self::PrincipalRequestType: |
||
| 53 | return new UserPrincipalRequest(); |
||
| 54 | case self::CalendarHomeRequestType: |
||
| 55 | return new CalendarHomeRequest(); |
||
| 56 | case self::CalendarsRequestType: |
||
| 57 | return new GetCalendarsRequest(); |
||
| 58 | case self::CalendarRequestType: |
||
| 59 | return new GetCalendarRequest(); |
||
| 60 | case self::CalendarSyncRequestType: |
||
| 61 | if(count($params) == 0 ) |
||
| 62 | throw new \InvalidArgumentException(); |
||
| 63 | return new CalendarSyncRequest($params[0]); |
||
| 64 | case self::CalendarMultiGetRequestType: |
||
| 65 | if(count($params) == 0 ) |
||
| 66 | throw new \InvalidArgumentException(); |
||
| 67 | return new CalendarMultiGetRequest($params[0]); |
||
| 68 | case self::CalendarQueryRequestType: |
||
| 69 | if(count($params) == 0 ) |
||
| 70 | throw new \InvalidArgumentException(); |
||
| 71 | return new CalendarQueryRequest($params[0]); |
||
| 72 | case self::CalendarCreateRequestType: |
||
| 73 | if(count($params) == 0 ) |
||
| 74 | throw new \InvalidArgumentException(); |
||
| 75 | return new CalendarCreateRequest($params[0]); |
||
| 76 | case self::EventCreateRequestType: |
||
| 77 | if(count($params) == 0 ) |
||
| 78 | throw new \InvalidArgumentException(); |
||
| 79 | return new EventCreateRequest($params[0]); |
||
| 80 | case self::EventUpdateRequestType: |
||
| 81 | if(count($params) == 0 ) |
||
| 82 | throw new \InvalidArgumentException(); |
||
| 83 | return new EventUpdateRequest($params[0]); |
||
| 84 | } |
||
| 85 | return null; |
||
| 86 | } |
||
| 87 | } |