Conditions | 15 |
Paths | 15 |
Total Lines | 32 |
Code Lines | 30 |
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 |
||
111 | public function api($name) { |
||
112 | switch ($name) { |
||
113 | case 'projects': |
||
114 | return $this->projects(); |
||
115 | case 'suites': |
||
116 | return $this->suites(); |
||
117 | case 'sections': |
||
118 | return $this->sections(); |
||
119 | case 'cases': |
||
120 | return $this->cases(); |
||
121 | case 'templates': |
||
122 | return $this->templates(); |
||
123 | case 'types': |
||
124 | return $this->types(); |
||
125 | case 'fields': |
||
126 | return $this->fields(); |
||
127 | case 'priorities': |
||
128 | return $this->priorities(); |
||
129 | case 'milestones': |
||
130 | return $this->milestones(); |
||
131 | case 'plans': |
||
132 | return $this->plans(); |
||
133 | case 'configurations': |
||
134 | return $this->configurations(); |
||
135 | case 'results': |
||
136 | return $this->results(); |
||
137 | case 'statuses': |
||
138 | return $this->statuses(); |
||
139 | case 'users': |
||
140 | return $this->users(); |
||
141 | } |
||
142 | return null; |
||
143 | } |
||
144 | } |