| Conditions | 25 |
| Paths | 1650 |
| Total Lines | 100 |
| Code Lines | 53 |
| 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 |
||
| 38 | public function handle(ServerRequestInterface $request): ResponseInterface |
||
| 39 | { |
||
| 40 | $tree = Validator::attributes($request)->tree(); |
||
| 41 | $xref = Validator::parsedBody($request)->isXref()->string('xref'); |
||
| 42 | $family = Registry::familyFactory()->make($xref, $tree); |
||
| 43 | $family = Auth::checkFamilyAccess($family, true); |
||
| 44 | |||
| 45 | $HUSB = Validator::parsedBody($request)->isXref()->string('HUSB', ''); |
||
| 46 | $WIFE = Validator::parsedBody($request)->isXref()->string('WIFE', ''); |
||
| 47 | $CHIL = Validator::parsedBody($request)->array('CHIL'); |
||
| 48 | |||
| 49 | // Current family members |
||
| 50 | $old_father = $family->husband(); |
||
| 51 | $old_mother = $family->wife(); |
||
| 52 | $old_children = $family->children(); |
||
| 53 | |||
| 54 | // New family members |
||
| 55 | $new_father = Registry::individualFactory()->make($HUSB, $tree); |
||
| 56 | $new_mother = Registry::individualFactory()->make($WIFE, $tree); |
||
| 57 | $new_children = []; |
||
| 58 | foreach ($CHIL as $child) { |
||
| 59 | $new_children[] = Registry::individualFactory()->make($child, $tree); |
||
| 60 | } |
||
| 61 | |||
| 62 | if ($old_father !== $new_father) { |
||
| 63 | if ($old_father instanceof Individual) { |
||
| 64 | // Remove old FAMS link |
||
| 65 | foreach ($old_father->facts(['FAMS']) as $fact) { |
||
| 66 | if ($fact->target() === $family) { |
||
| 67 | $old_father->deleteFact($fact->id(), true); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | // Remove old HUSB link |
||
| 71 | foreach ($family->facts(['HUSB', 'WIFE']) as $fact) { |
||
| 72 | if ($fact->target() === $old_father) { |
||
| 73 | $family->deleteFact($fact->id(), true); |
||
| 74 | } |
||
| 75 | } |
||
| 76 | } |
||
| 77 | if ($new_father instanceof Individual) { |
||
| 78 | // Add new FAMS link |
||
| 79 | $before = $this->famsFactOfLaterMarriage($new_father, $family); |
||
| 80 | $new_father->createFact('1 FAMS @' . $family->xref() . '@', true, $before); |
||
| 81 | // Add new HUSB link |
||
| 82 | $family->createFact('1 HUSB @' . $new_father->xref() . '@', true); |
||
| 83 | } |
||
| 84 | } |
||
| 85 | |||
| 86 | if ($old_mother !== $new_mother) { |
||
| 87 | if ($old_mother instanceof Individual) { |
||
| 88 | // Remove old FAMS link |
||
| 89 | foreach ($old_mother->facts(['FAMS']) as $fact) { |
||
| 90 | if ($fact->target() === $family) { |
||
| 91 | $old_mother->deleteFact($fact->id(), true); |
||
| 92 | } |
||
| 93 | } |
||
| 94 | // Remove old WIFE link |
||
| 95 | foreach ($family->facts(['HUSB', 'WIFE']) as $fact) { |
||
| 96 | if ($fact->target() === $old_mother) { |
||
| 97 | $family->deleteFact($fact->id(), true); |
||
| 98 | } |
||
| 99 | } |
||
| 100 | } |
||
| 101 | if ($new_mother instanceof Individual) { |
||
| 102 | // Add new FAMS link |
||
| 103 | $before = $this->famsFactOfLaterMarriage($new_mother, $family); |
||
| 104 | $new_mother->createFact('1 FAMS @' . $family->xref() . '@', true, $before); |
||
| 105 | // Add new WIFE link |
||
| 106 | $family->createFact('1 WIFE @' . $new_mother->xref() . '@', true); |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | foreach ($old_children as $old_child) { |
||
| 111 | if (!in_array($old_child, $new_children, true)) { |
||
| 112 | // Remove old FAMC link |
||
| 113 | foreach ($old_child->facts(['FAMC']) as $fact) { |
||
| 114 | if ($fact->target() === $family) { |
||
| 115 | $old_child->deleteFact($fact->id(), true); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | // Remove old CHIL link |
||
| 119 | foreach ($family->facts(['CHIL']) as $fact) { |
||
| 120 | if ($fact->target() === $old_child) { |
||
| 121 | $family->deleteFact($fact->id(), true); |
||
| 122 | } |
||
| 123 | } |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | foreach ($new_children as $new_child) { |
||
| 128 | if ($new_child instanceof Individual && !$old_children->contains($new_child)) { |
||
| 129 | // Add new FAMC link |
||
| 130 | $new_child->createFact('1 FAMC @' . $family->xref() . '@', true); |
||
| 131 | // Add new CHIL link |
||
| 132 | $before = $this->childFactOfYoungerSibling($family, $new_child); |
||
| 133 | $family->createFact('1 CHIL @' . $new_child->xref() . '@', true, $before); |
||
| 134 | } |
||
| 135 | } |
||
| 136 | |||
| 137 | return redirect($family->url()); |
||
| 138 | } |
||
| 162 |
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