| Conditions | 10 |
| Paths | 90 |
| Total Lines | 55 |
| Code Lines | 38 |
| 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 |
||
| 53 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
| 54 | { |
||
| 55 | $tree = Validator::attributes($request)->tree(); |
||
| 56 | $xref = Validator::attributes($request)->isXref()->string('xref'); |
||
| 57 | $individual = Registry::individualFactory()->make($xref, $tree); |
||
| 58 | $individual = Auth::checkIndividualAccess($individual, true); |
||
| 59 | $famid = Validator::parsedBody($request)->isXref()->string('famid'); |
||
| 60 | $PEDI = Validator::parsedBody($request)->string('PEDI'); |
||
| 61 | |||
| 62 | $family = Registry::familyFactory()->make($famid, $tree); |
||
| 63 | $family = Auth::checkFamilyAccess($family, true); |
||
| 64 | |||
| 65 | // Replace any existing child->family link (we may be changing the PEDI); |
||
| 66 | $fact_id = ''; |
||
| 67 | foreach ($individual->facts(['FAMC']) as $fact) { |
||
| 68 | if ($family === $fact->target()) { |
||
| 69 | $fact_id = $fact->id(); |
||
| 70 | break; |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | switch ($PEDI) { |
||
| 75 | case '': |
||
| 76 | $gedcom = "1 FAMC @$famid@"; |
||
| 77 | break; |
||
| 78 | case PedigreeLinkageType::VALUE_ADOPTED: |
||
| 79 | $gedcom = "1 FAMC @$famid@\n2 PEDI $PEDI\n1 ADOP\n2 FAMC @$famid@\n3 ADOP BOTH"; |
||
| 80 | break; |
||
| 81 | case PedigreeLinkageType::VALUE_SEALING: |
||
| 82 | $gedcom = "1 FAMC @$famid@\n2 PEDI $PEDI\n1 SLGC\n2 FAMC @$famid@"; |
||
| 83 | break; |
||
| 84 | case PedigreeLinkageType::VALUE_FOSTER: |
||
| 85 | $gedcom = "1 FAMC @$famid@\n2 PEDI $PEDI\n1 EVEN\n2 TYPE $PEDI"; |
||
| 86 | break; |
||
| 87 | default: |
||
| 88 | $gedcom = "1 FAMC @$famid@\n2 PEDI $PEDI"; |
||
| 89 | break; |
||
| 90 | } |
||
| 91 | |||
| 92 | $individual->updateFact($fact_id, $gedcom, true); |
||
| 93 | |||
| 94 | // Only set the family->child link if it does not already exist |
||
| 95 | $chil_link_exists = false; |
||
| 96 | foreach ($family->facts(['CHIL']) as $fact) { |
||
| 97 | if ($individual === $fact->target()) { |
||
| 98 | $chil_link_exists = true; |
||
| 99 | break; |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | if (!$chil_link_exists) { |
||
| 104 | $this->family_service->addChildToFamily($individual, $family); |
||
| 105 | } |
||
| 106 | |||
| 107 | return redirect($individual->url()); |
||
| 108 | } |
||
| 110 |
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