Conditions | 16 |
Paths | 16 |
Total Lines | 106 |
Code Lines | 82 |
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 |
||
185 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
186 | { |
||
187 | $topic = $request->getAttribute('topic'); |
||
188 | |||
189 | $dmy = I18N::language()->dateOrder(); |
||
190 | |||
191 | switch ($topic) { |
||
192 | case 'DATE': |
||
193 | switch ($dmy) { |
||
194 | case 'YMD': |
||
195 | $date_shortcuts = self::DATE_SHORTCUTS + self::YMD_SHORTCUTS; |
||
196 | break; |
||
197 | case 'MDY': |
||
198 | $date_shortcuts = self::DATE_SHORTCUTS + self::MDY_SHORTCUTS; |
||
199 | break; |
||
200 | case 'DMY': |
||
201 | default: |
||
202 | $date_shortcuts = self::DATE_SHORTCUTS + self::DMY_SHORTCUTS; |
||
203 | break; |
||
204 | } |
||
205 | |||
206 | $title = I18N::translate('Date'); |
||
207 | $text = view('help/date', [ |
||
208 | 'date_dates' => $this->formatDates(array_keys($date_shortcuts)), |
||
209 | 'date_shortcuts' => $date_shortcuts, |
||
210 | 'date_period_dates' => $this->formatDates(array_keys(self::DATE_PERIOD_SHORTCUTS)), |
||
211 | 'date_period_shortcuts' => self::DATE_PERIOD_SHORTCUTS, |
||
212 | 'date_range_dates' => $this->formatDates(array_keys(self::DATE_RANGE_SHORTCUTS)), |
||
213 | 'date_range_shortcuts' => self::DATE_RANGE_SHORTCUTS, |
||
214 | 'french_dates' => $this->formatDates(self::FRENCH_DATES), |
||
215 | 'hijri_dates' => $this->formatDates(self::HIJRI_DATES), |
||
216 | 'jalali_dates' => $this->formatDates(self::JALALI_DATES), |
||
217 | 'jewish_dates' => $this->formatDates(self::JEWISH_DATES), |
||
218 | 'julian_dates' => $this->formatDates(self::JULIAN_DATES), |
||
219 | ]); |
||
220 | break; |
||
221 | |||
222 | case 'NAME': |
||
223 | $title = I18N::translate('Name'); |
||
224 | $text = view('help/name'); |
||
225 | break; |
||
226 | |||
227 | case 'SURN': |
||
228 | $title = I18N::translate('Surname'); |
||
229 | $text = view('help/surname'); |
||
230 | break; |
||
231 | |||
232 | case 'OBJE': |
||
233 | $title = I18N::translate('Media object'); |
||
234 | $text = view('help/media-object'); |
||
235 | break; |
||
236 | |||
237 | case 'PLAC': |
||
238 | $title = I18N::translate('Place'); |
||
239 | $text = view('help/place'); |
||
240 | break; |
||
241 | |||
242 | case 'RESN': |
||
243 | $title = I18N::translate('Restriction'); |
||
244 | $text = view('help/restriction'); |
||
245 | break; |
||
246 | |||
247 | case 'ROMN': |
||
248 | $title = I18N::translate('Romanized'); |
||
249 | $text = view('help/romanized'); |
||
250 | break; |
||
251 | |||
252 | case '_HEB': |
||
253 | $title = I18N::translate('Hebrew'); |
||
254 | $text = view('help/hebrew'); |
||
255 | break; |
||
256 | |||
257 | case 'data-fixes': |
||
258 | $title = I18N::translate('Data fixes'); |
||
259 | $text = view('help/data-fixes'); |
||
260 | break; |
||
261 | |||
262 | case 'edit_SOUR_EVEN': |
||
263 | $title = I18N::translate('Associate events with this source'); |
||
264 | $text = view('help/source-events'); |
||
265 | break; |
||
266 | |||
267 | case 'pending_changes': |
||
268 | $title = I18N::translate('Pending changes'); |
||
269 | $text = view('help/pending-changes', [ |
||
270 | 'is_admin' => Auth::isAdmin(), |
||
271 | ]); |
||
272 | break; |
||
273 | |||
274 | case 'relationship-privacy': |
||
275 | $title = I18N::translate('Restrict to immediate family'); |
||
276 | $text = view('help/relationship-privacy'); |
||
277 | break; |
||
278 | |||
279 | default: |
||
280 | $title = I18N::translate('Help'); |
||
281 | $text = I18N::translate('The help text has not been written for this item.'); |
||
282 | break; |
||
283 | } |
||
284 | |||
285 | $html = view('modals/help', [ |
||
286 | 'title' => $title, |
||
287 | 'text' => $text, |
||
288 | ]); |
||
289 | |||
290 | return response($html); |
||
291 | } |
||
315 |