| Conditions | 1 |
| Paths | 1 |
| Total Lines | 109 |
| Code Lines | 73 |
| 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 |
||
| 77 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
| 78 | { |
||
| 79 | $this->layout = 'layouts/administration'; |
||
| 80 | |||
| 81 | $tree = Validator::attributes($request)->tree(); |
||
| 82 | $data_folder = Registry::filesystem()->dataName(); |
||
| 83 | |||
| 84 | $french_calendar_start = new Date('22 SEP 1792'); |
||
| 85 | $french_calendar_end = new Date('31 DEC 1805'); |
||
| 86 | $gregorian_calendar_start = new Date('15 OCT 1582'); |
||
| 87 | |||
| 88 | $surname_list_styles = [ |
||
| 89 | /* I18N: Layout option for lists of names */ |
||
| 90 | 'style1' => I18N::translate('list'), |
||
| 91 | /* I18N: Layout option for lists of names */ |
||
| 92 | 'style2' => I18N::translate('table'), |
||
| 93 | /* I18N: Layout option for lists of names */ |
||
| 94 | 'style3' => I18N::translate('tag cloud'), |
||
| 95 | ]; |
||
| 96 | |||
| 97 | $page_layouts = [ |
||
| 98 | /* I18N: page orientation */ |
||
| 99 | 0 => I18N::translate('Portrait'), |
||
| 100 | /* I18N: page orientation */ |
||
| 101 | 1 => I18N::translate('Landscape'), |
||
| 102 | ]; |
||
| 103 | |||
| 104 | $formats = [ |
||
| 105 | /* I18N: https://en.wikipedia.org/wiki/Plain_text */ |
||
| 106 | '' => I18N::translate('plain text'), |
||
| 107 | /* I18N: https://en.wikipedia.org/wiki/Markdown */ |
||
| 108 | 'markdown' => I18N::translate('markdown'), |
||
| 109 | ]; |
||
| 110 | |||
| 111 | $source_types = [ |
||
| 112 | 0 => I18N::translate('none'), |
||
| 113 | 1 => I18N::translate('facts'), |
||
| 114 | 2 => I18N::translate('records'), |
||
| 115 | ]; |
||
| 116 | |||
| 117 | $theme_options = $this->module_service |
||
| 118 | ->findByInterface(ModuleThemeInterface::class) |
||
| 119 | ->map($this->module_service->titleMapper()) |
||
| 120 | ->prepend(I18N::translate('<default theme>'), ''); |
||
| 121 | |||
| 122 | $privacy_options = [ |
||
| 123 | Auth::PRIV_USER => I18N::translate('Show to members'), |
||
| 124 | Auth::PRIV_NONE => I18N::translate('Show to managers'), |
||
| 125 | Auth::PRIV_HIDE => I18N::translate('Hide from everyone'), |
||
| 126 | ]; |
||
| 127 | |||
| 128 | // For historical reasons, we have two fields in one |
||
| 129 | $calendar_formats = explode('_and_', $tree->getPreference('CALENDAR_FORMAT') . '_and_'); |
||
| 130 | |||
| 131 | // Split into separate fields |
||
| 132 | $relatives_events = explode(',', $tree->getPreference('SHOW_RELATIVES_EVENTS')); |
||
| 133 | |||
| 134 | $pedigree_individual = Registry::individualFactory()->make($tree->getPreference('PEDIGREE_ROOT_ID'), $tree); |
||
| 135 | |||
| 136 | $members = $this->user_service->all()->filter(static fn (UserInterface $user): bool => Auth::isMember($tree, $user)); |
||
| 137 | |||
| 138 | $ignore_facts = ['CHAN', 'CHIL', 'FAMC', 'FAMS', 'HUSB', 'SUBM', 'WIFE', 'NAME', 'SEX']; |
||
| 139 | |||
| 140 | $all_family_facts = Collection::make(Registry::elementFactory()->make('FAM')->subtags()) |
||
| 141 | ->filter(static fn (string $value, string $key): bool => !in_array($key, $ignore_facts, true)) |
||
| 142 | ->mapWithKeys(static fn (string $value, string $key): array => [$key => 'FAM:' . $key]) |
||
| 143 | ->map(static fn (string $tag): ElementInterface => Registry::elementFactory()->make($tag)) |
||
| 144 | ->filter(static fn (ElementInterface $element): bool => !$element instanceof UnknownElement) |
||
| 145 | ->map(static fn (ElementInterface $element): string => $element->label()) |
||
| 146 | ->sort(I18N::comparator()); |
||
| 147 | |||
| 148 | $all_individual_facts = Collection::make(Registry::elementFactory()->make('INDI')->subtags()) |
||
| 149 | ->filter(static fn (string $value, string $key): bool => !in_array($key, $ignore_facts, true)) |
||
| 150 | ->mapWithKeys(static fn (string $value, string $key): array => [$key => 'INDI:' . $key]) |
||
| 151 | ->map(static fn (string $tag): ElementInterface => Registry::elementFactory()->make($tag)) |
||
| 152 | ->filter(static fn (ElementInterface $element): bool => !$element instanceof UnknownElement) |
||
| 153 | ->map(static fn (ElementInterface $element): string => $element->label()) |
||
| 154 | ->sort(I18N::comparator()); |
||
| 155 | |||
| 156 | $all_surname_traditions = Registry::surnameTraditionFactory()->list(); |
||
| 157 | |||
| 158 | $tree_count = $this->tree_service->all()->count(); |
||
| 159 | |||
| 160 | $title = I18N::translate('Preferences') . ' — ' . e($tree->title()); |
||
| 161 | |||
| 162 | $base_url = Validator::attributes($request)->string('base_url'); |
||
| 163 | |||
| 164 | return $this->viewResponse('admin/trees-preferences', [ |
||
| 165 | 'all_family_facts' => $all_family_facts, |
||
| 166 | 'all_individual_facts' => $all_individual_facts, |
||
| 167 | 'all_surname_traditions' => $all_surname_traditions, |
||
| 168 | 'base_url' => $base_url, |
||
| 169 | 'calendar_formats' => $calendar_formats, |
||
| 170 | 'data_folder' => $data_folder, |
||
| 171 | 'formats' => $formats, |
||
| 172 | 'french_calendar_end' => $french_calendar_end, |
||
| 173 | 'french_calendar_start' => $french_calendar_start, |
||
| 174 | 'gregorian_calendar_start' => $gregorian_calendar_start, |
||
| 175 | 'members' => $members, |
||
| 176 | 'page_layouts' => $page_layouts, |
||
| 177 | 'pedigree_individual' => $pedigree_individual, |
||
| 178 | 'privacy_options' => $privacy_options, |
||
| 179 | 'relatives_events' => $relatives_events, |
||
| 180 | 'source_types' => $source_types, |
||
| 181 | 'surname_list_styles' => $surname_list_styles, |
||
| 182 | 'theme_options' => $theme_options, |
||
| 183 | 'title' => $title, |
||
| 184 | 'tree' => $tree, |
||
| 185 | 'tree_count' => $tree_count, |
||
| 186 | ]); |
||
| 189 |
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