Conditions | 11 |
Paths | 2 |
Total Lines | 34 |
Code Lines | 27 |
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 |
||
85 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
86 | { |
||
87 | $tree = Validator::attributes($request)->tree(); |
||
88 | $xref = Validator::attributes($request)->isXref()->string('xref'); |
||
89 | $record = Registry::gedcomRecordFactory()->make($xref, $tree); |
||
90 | $record = Auth::checkRecordAccess($record); |
||
91 | |||
92 | // Standard genealogy records have their own pages. |
||
93 | if ($record->xref() !== $xref || in_array(get_class($record), self::STANDARD_RECORDS, true)) { |
||
94 | return Registry::responseFactory()->redirectUrl($record->url()); |
||
95 | } |
||
96 | |||
97 | $linked_families = $this->linked_record_service->linkedFamilies($record); |
||
98 | $linked_individuals = $this->linked_record_service->linkedIndividuals($record); |
||
99 | $linked_locations = $this->linked_record_service->linkedLocations($record); |
||
100 | $linked_media = $this->linked_record_service->linkedMedia($record); |
||
101 | $linked_notes = $this->linked_record_service->linkedNotes($record); |
||
102 | $linked_repositories = $this->linked_record_service->linkedRepositories($record); |
||
103 | $linked_sources = $this->linked_record_service->linkedSources($record); |
||
104 | $linked_submitters = $this->linked_record_service->linkedSubmitters($record); |
||
105 | |||
106 | return $this->viewResponse('record-page', [ |
||
107 | 'clipboard_facts' => $this->clipboard_service->pastableFacts($record), |
||
108 | 'linked_families' => $linked_families->isEmpty() ? null : $linked_families, |
||
109 | 'linked_individuals' => $linked_individuals->isEmpty() ? null : $linked_individuals, |
||
110 | 'linked_locations' => $linked_locations->isEmpty() ? null : $linked_locations, |
||
111 | 'linked_media_objects' => $linked_media->isEmpty() ? null : $linked_media, |
||
112 | 'linked_notes' => $linked_notes->isEmpty() ? null : $linked_notes, |
||
113 | 'linked_repositories' => $linked_repositories->isEmpty() ? null : $linked_repositories, |
||
114 | 'linked_sources' => $linked_sources->isEmpty() ? null : $linked_sources, |
||
115 | 'linked_submitters' => $linked_submitters->isEmpty() ? null : $linked_submitters, |
||
116 | 'record' => $record, |
||
117 | 'title' => $record->fullName(), |
||
118 | 'tree' => $tree, |
||
119 | ]); |
||
122 |