Conditions | 12 |
Paths | 12 |
Total Lines | 53 |
Code Lines | 30 |
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 |
||
59 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
60 | { |
||
61 | $tree = Validator::attributes($request)->tree(); |
||
62 | $xref = Validator::attributes($request)->isXref()->string('xref'); |
||
63 | $fact_id = Validator::attributes($request)->string('fact_id'); |
||
64 | |||
65 | $record = Registry::gedcomRecordFactory()->make($xref, $tree); |
||
66 | $record = Auth::checkRecordAccess($record, true); |
||
67 | |||
68 | $keep_chan = Validator::parsedBody($request)->boolean('keep_chan', false); |
||
69 | $levels = Validator::parsedBody($request)->array('levels'); |
||
70 | $tags = Validator::parsedBody($request)->array('tags'); |
||
71 | $values = Validator::parsedBody($request)->array('values'); |
||
72 | $gedcom = $this->gedcom_edit_service->editLinesToGedcom($record::RECORD_TYPE, $levels, $tags, $values, false); |
||
73 | |||
74 | $census_assistant = $this->module_service->findByInterface(CensusAssistantModule::class)->first(); |
||
75 | |||
76 | if ($census_assistant instanceof CensusAssistantModule && $record instanceof Individual) { |
||
77 | $ca_individuals = Validator::parsedBody($request)->array('ca_individuals')['xref'] ?? []; |
||
78 | |||
79 | if ($ca_individuals !== []) { |
||
80 | $gedcom = $census_assistant->updateCensusAssistant($request, $record, $fact_id, $gedcom, $keep_chan); |
||
81 | |||
82 | // Don't copy the AGE/OCCU fields to other individuals |
||
83 | $gedcom2 = preg_replace('/\n2 (?:AGE|OCCU) .*/', '', $gedcom); |
||
84 | |||
85 | foreach ($ca_individuals as $pid) { |
||
86 | if ($pid !== $xref) { |
||
87 | $individual = Registry::individualFactory()->make($pid, $tree); |
||
88 | if ($individual instanceof Individual && $individual->canEdit()) { |
||
89 | $individual->updateFact('', $gedcom2, !$keep_chan); |
||
90 | } |
||
91 | } |
||
92 | } |
||
93 | } |
||
94 | } |
||
95 | |||
96 | if ($fact_id === 'new') { |
||
97 | // Add a new fact |
||
98 | $record->updateFact('', $gedcom, !$keep_chan); |
||
99 | } else { |
||
100 | // Update (only the first copy of) an existing fact |
||
101 | foreach ($record->facts([], false, null, true) as $fact) { |
||
102 | if ($fact->id() === $fact_id && $fact->canEdit()) { |
||
103 | $record->updateFact($fact_id, $gedcom, !$keep_chan); |
||
104 | break; |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | |||
109 | $url = Validator::parsedBody($request)->isLocalUrl()->string('url', $record->url()); |
||
110 | |||
111 | return redirect($url); |
||
112 | } |
||
114 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths