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