Conditions | 13 |
Paths | 1 |
Total Lines | 30 |
Code Lines | 23 |
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 |
||
53 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
54 | { |
||
55 | $this->layout = 'layouts/administration'; |
||
56 | |||
57 | $tree = $request->getAttribute('tree'); |
||
58 | assert($tree instanceof Tree); |
||
59 | |||
60 | $xref1 = $request->getQueryParams()['xref1'] ?? ''; |
||
61 | $xref2 = $request->getQueryParams()['xref2'] ?? ''; |
||
62 | |||
63 | $record1 = GedcomRecord::getInstance($xref1, $tree); |
||
64 | $record2 = GedcomRecord::getInstance($xref2, $tree); |
||
65 | |||
66 | $title = I18N::translate('Merge records') . ' — ' . e($tree->title()); |
||
67 | |||
68 | return $this->viewResponse('admin/merge-records-step-1', [ |
||
69 | 'individual1' => $record1 instanceof Individual ? $record1 : null, |
||
70 | 'individual2' => $record2 instanceof Individual ? $record2 : null, |
||
71 | 'family1' => $record1 instanceof Family ? $record1 : null, |
||
72 | 'family2' => $record2 instanceof Family ? $record2 : null, |
||
73 | 'source1' => $record1 instanceof Source ? $record1 : null, |
||
74 | 'source2' => $record2 instanceof Source ? $record2 : null, |
||
75 | 'repository1' => $record1 instanceof Repository ? $record1 : null, |
||
76 | 'repository2' => $record2 instanceof Repository ? $record2 : null, |
||
77 | 'media1' => $record1 instanceof Media ? $record1 : null, |
||
78 | 'media2' => $record2 instanceof Media ? $record2 : null, |
||
79 | 'note1' => $record1 instanceof Note ? $record1 : null, |
||
80 | 'note2' => $record2 instanceof Note ? $record2 : null, |
||
81 | 'title' => $title, |
||
82 | 'tree' => $tree, |
||
83 | ]); |
||
86 |