| Conditions | 34 |
| Paths | 1025 |
| Total Lines | 86 |
| Code Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 33 | public static function insertFamilyData($conn, $persons_id, $families, $obje_ids, $sour_ids, $note_ids = [], $repo_ids = []) |
||
| 34 | { |
||
| 35 | foreach ($families as $family) { |
||
| 36 | $g_id = $family->getId(); |
||
| 37 | $husb = $family->getHusb(); |
||
| 38 | $wife = $family->getWife(); |
||
| 39 | $husband_id = $persons_id[$husb] ?? 0; |
||
| 40 | $wife_id = $persons_id[$wife] ?? 0; |
||
| 41 | $children = $family->getChil(); |
||
| 42 | $events = $family->getAllEven(); |
||
| 43 | $subm = $family->getSubm(); |
||
| 44 | $_slgs = $family->getSlgs(); |
||
| 45 | $_note = $family->getNote(); |
||
| 46 | $_obje = $family->getObje(); |
||
| 47 | $_sour = $family->getSour(); |
||
| 48 | $_refn = $family->getRefn(); |
||
| 49 | $chan = $family->getChan(); |
||
| 50 | $familie = Family::on($conn)->where('husband_id', $husband_id)->where('wife_id', $wife_id)->first(); |
||
| 51 | if ($children !== null) { |
||
| 52 | foreach ($children as $child) { |
||
| 53 | if (isset($persons_id[$child])) { |
||
| 54 | $person = Person::on($conn)->find($persons_id[$child]); |
||
| 55 | $person->child_in_family_id = $familie->id; |
||
| 56 | $person->save(); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | if ($events !== null && count($events) > 0) { |
||
| 62 | foreach ($events as $item) { |
||
| 63 | if ($item) { |
||
| 64 | Even::read($conn, $item, $familie, $obje_ids); |
||
| 65 | } |
||
| 66 | // $date = $getDate($item->getDate()); |
||
| 67 | // $place = $getPlace($item->getPlac()); |
||
| 68 | // $family->addEvent($item->getType(), $date, $place); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | $_group = 'fam'; |
||
| 72 | if ($familie == null) { |
||
| 73 | $_gid = 0; |
||
| 74 | } else { |
||
| 75 | $_gid = $familie->id; |
||
| 76 | } |
||
| 77 | if ($_note != null && count($_note) > 0) { |
||
| 78 | foreach ($_note as $item) { |
||
| 79 | NoteRef::read($conn, $item, $_group, $_gid); |
||
| 80 | } |
||
| 81 | } |
||
| 82 | if ($_obje && count($_obje) > 0) { |
||
| 83 | foreach ($_obje as $item) { |
||
| 84 | if ($item) { |
||
| 85 | ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | if ($_refn && count($_refn) > 0) { |
||
| 90 | foreach ($_refn as $item) { |
||
| 91 | if ($item) { |
||
| 92 | Refn::read($conn, $item, $_group, $_gid); |
||
| 93 | } |
||
| 94 | } |
||
| 95 | } |
||
| 96 | if ($_sour && count($_sour) > 0) { |
||
| 97 | foreach ($_sour as $item) { |
||
| 98 | if ($item) { |
||
| 99 | SourRef::read($conn, $item, $_group, $_gid, $sour_ids, $obje_ids); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | } |
||
| 103 | if ($_slgs && count($_slgs) > 0) { |
||
| 104 | foreach ($_slgs as $item) { |
||
| 105 | if ($item) { |
||
| 106 | Slgs::read($conn, $item, $familie); |
||
| 107 | } |
||
| 108 | } |
||
| 109 | } |
||
| 110 | if ($subm && count($subm) > 0) { |
||
| 111 | foreach ($subm as $item) { |
||
| 112 | if ($item) { |
||
| 113 | Subm::read($conn, $item, $_group, $_gid, $obje_ids); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } |
||
| 117 | if ($chan) { |
||
| 118 | Chan::read($conn, $chan, 'family', $familie->id); |
||
| 119 | } |
||
| 123 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.