| Conditions | 8 |
| Paths | 96 |
| Total Lines | 62 |
| Code Lines | 40 |
| 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 |
||
| 31 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
| 32 | { |
||
| 33 | $tree = Validator::attributes($request)->tree(); |
||
| 34 | $title = Validator::parsedBody($request)->isNotEmpty()->string('source-title'); |
||
| 35 | $abbreviation = Validator::parsedBody($request)->string('source-abbreviation'); |
||
| 36 | $author = Validator::parsedBody($request)->string('source-author'); |
||
| 37 | $publication = Validator::parsedBody($request)->string('source-publication'); |
||
| 38 | $repository = Validator::parsedBody($request)->isXref()->string('source-repository', ''); |
||
| 39 | $call_number = Validator::parsedBody($request)->string('source-call-number'); |
||
| 40 | $text = Validator::parsedBody($request)->string('source-text'); |
||
| 41 | $restriction = Validator::parsedBody($request)->string('restriction'); |
||
| 42 | |||
| 43 | $title = Registry::elementFactory()->make('SOUR:TITL')->canonical($title); |
||
| 44 | $abbreviation = Registry::elementFactory()->make('SOUR:ABBR')->canonical($abbreviation); |
||
| 45 | $author = Registry::elementFactory()->make('SOUR:AUTH')->canonical($author); |
||
| 46 | $publication = Registry::elementFactory()->make('SOUR:PUBL')->canonical($publication); |
||
| 47 | $repository = Registry::elementFactory()->make('SOUR:REPO')->canonical($repository); |
||
| 48 | $call_number = Registry::elementFactory()->make('SOUR:REPO:CALN')->canonical($call_number); |
||
| 49 | $text = Registry::elementFactory()->make('SOUR:TEXT')->canonical($text); |
||
| 50 | $restriction = Registry::elementFactory()->make('SOUR:RESN')->canonical($restriction); |
||
| 51 | |||
| 52 | $gedcom = "0 @@ SOUR\n1 TITL " . strtr($title, ["\n" => "\n2 CONT "]); |
||
| 53 | |||
| 54 | if ($abbreviation !== '') { |
||
| 55 | $gedcom .= "\n1 ABBR " . strtr($abbreviation, ["\n" => "\n2 CONT "]); |
||
| 56 | } |
||
| 57 | |||
| 58 | if ($author !== '') { |
||
| 59 | $gedcom .= "\n1 AUTH " . strtr($author, ["\n" => "\n2 CONT "]); |
||
| 60 | } |
||
| 61 | |||
| 62 | if ($publication !== '') { |
||
| 63 | $gedcom .= "\n1 PUBL " . strtr($publication, ["\n" => "\n2 CONT "]); |
||
| 64 | } |
||
| 65 | |||
| 66 | if ($text !== '') { |
||
| 67 | $gedcom .= "\n1 TEXT " . strtr($text, ["\n" => "\n2 CONT "]); |
||
| 68 | } |
||
| 69 | |||
| 70 | if ($repository !== '') { |
||
| 71 | $gedcom .= "\n1 REPO @" . $repository . '@'; |
||
| 72 | |||
| 73 | if ($call_number !== '') { |
||
| 74 | $gedcom .= "\n2 CALN " . strtr($call_number, ["\n" => "\n3 CONT "]); |
||
| 75 | } |
||
| 76 | } |
||
| 77 | |||
| 78 | if ($restriction !== '') { |
||
| 79 | $gedcom .= "\n1 RESN " . strtr($restriction, ["\n" => "\n2 CONT "]); |
||
| 80 | } |
||
| 81 | |||
| 82 | $record = $tree->createRecord($gedcom); |
||
| 83 | |||
| 84 | // value and text are for autocomplete |
||
| 85 | // html is for interactive modals |
||
| 86 | return response([ |
||
| 87 | 'value' => '@' . $record->xref() . '@', |
||
| 88 | 'text' => view('selects/source', ['source' => $record]), |
||
| 89 | 'html' => view('modals/record-created', [ |
||
| 90 | 'title' => I18N::translate('The source has been created'), |
||
| 91 | 'name' => $record->fullName(), |
||
| 92 | 'url' => $record->url(), |
||
| 93 | ]), |
||
| 97 |
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