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