| Conditions | 11 |
| Paths | 37 |
| Total Lines | 53 |
| Code Lines | 33 |
| 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 |
||
| 17 | public static function read($conn, $slgs, $fam) |
||
| 18 | { |
||
| 19 | try |
||
| 20 | { |
||
| 21 | if ($slgs == null || $fam === null) { |
||
| 22 | return; |
||
| 23 | } |
||
| 24 | |||
| 25 | $stat = $slgs->getStat(); |
||
| 26 | $date = $slgs->getDate(); |
||
| 27 | $plac = $slgs->getPlac(); |
||
| 28 | $temp = $slgs->getTemp(); |
||
| 29 | |||
| 30 | $key = [ |
||
| 31 | 'family_id'=> $fam->id, |
||
| 32 | 'stat' => $stat, |
||
| 33 | 'date' => $date, |
||
| 34 | 'plac' => $plac, |
||
| 35 | 'temp' => $temp, |
||
| 36 | ]; |
||
| 37 | $data = [ |
||
| 38 | 'family_id'=> $fam->id, |
||
| 39 | 'stat' => $stat, |
||
| 40 | 'date' => $date, |
||
| 41 | 'plac' => $plac, |
||
| 42 | 'temp' => $temp, |
||
| 43 | ]; |
||
| 44 | |||
| 45 | $record = FamilySlgs::on($conn)->updateOrCreate($key, $data); |
||
| 46 | |||
| 47 | $_group = 'fam_slgs'; |
||
| 48 | $_gid = $record->id; |
||
| 49 | |||
| 50 | // array |
||
| 51 | $sour = $slgs->getSour(); |
||
| 52 | if ($sour && count($sour) > 0) { |
||
| 53 | foreach ($sour as $item) { |
||
| 54 | if ($item) { |
||
| 55 | \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $item, $_group, $_gid); |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |
||
| 59 | |||
| 60 | $note = $slgs->getNote(); |
||
| 61 | if ($note && count($note) > 0) { |
||
| 62 | foreach ($note as $item) { |
||
| 63 | \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 | catch(Throwable $e) |
||
| 68 | { |
||
| 69 | report($e); |
||
|
|
|||
| 70 | } |
||
| 73 |