Conditions | 23 |
Paths | 23 |
Total Lines | 52 |
Code Lines | 47 |
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 |
||
130 | private function centuryName(int $century): string |
||
131 | { |
||
132 | if ($century < 0) { |
||
133 | return I18N::translate('%s BCE', $this->centuryName(-$century)); |
||
134 | } |
||
135 | |||
136 | // The current chart engine (Google charts) can't handle <sup></sup> markup |
||
137 | switch ($century) { |
||
138 | case 21: |
||
139 | return strip_tags(I18N::translateContext('CENTURY', '21st')); |
||
140 | case 20: |
||
141 | return strip_tags(I18N::translateContext('CENTURY', '20th')); |
||
142 | case 19: |
||
143 | return strip_tags(I18N::translateContext('CENTURY', '19th')); |
||
144 | case 18: |
||
145 | return strip_tags(I18N::translateContext('CENTURY', '18th')); |
||
146 | case 17: |
||
147 | return strip_tags(I18N::translateContext('CENTURY', '17th')); |
||
148 | case 16: |
||
149 | return strip_tags(I18N::translateContext('CENTURY', '16th')); |
||
150 | case 15: |
||
151 | return strip_tags(I18N::translateContext('CENTURY', '15th')); |
||
152 | case 14: |
||
153 | return strip_tags(I18N::translateContext('CENTURY', '14th')); |
||
154 | case 13: |
||
155 | return strip_tags(I18N::translateContext('CENTURY', '13th')); |
||
156 | case 12: |
||
157 | return strip_tags(I18N::translateContext('CENTURY', '12th')); |
||
158 | case 11: |
||
159 | return strip_tags(I18N::translateContext('CENTURY', '11th')); |
||
160 | case 10: |
||
161 | return strip_tags(I18N::translateContext('CENTURY', '10th')); |
||
162 | case 9: |
||
163 | return strip_tags(I18N::translateContext('CENTURY', '9th')); |
||
164 | case 8: |
||
165 | return strip_tags(I18N::translateContext('CENTURY', '8th')); |
||
166 | case 7: |
||
167 | return strip_tags(I18N::translateContext('CENTURY', '7th')); |
||
168 | case 6: |
||
169 | return strip_tags(I18N::translateContext('CENTURY', '6th')); |
||
170 | case 5: |
||
171 | return strip_tags(I18N::translateContext('CENTURY', '5th')); |
||
172 | case 4: |
||
173 | return strip_tags(I18N::translateContext('CENTURY', '4th')); |
||
174 | case 3: |
||
175 | return strip_tags(I18N::translateContext('CENTURY', '3rd')); |
||
176 | case 2: |
||
177 | return strip_tags(I18N::translateContext('CENTURY', '2nd')); |
||
178 | case 1: |
||
179 | return strip_tags(I18N::translateContext('CENTURY', '1st')); |
||
180 | default: |
||
181 | return ($century - 1) . '01-' . $century . '00'; |
||
182 | } |
||
185 |