Conditions | 11 |
Paths | 16 |
Total Lines | 71 |
Code Lines | 49 |
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 |
||
14 | public static function read($conn, \Gedcom\Record\Indi\Name $item, $group = '', $group_id = 0) |
||
15 | { |
||
16 | $name = $item->getName(); |
||
17 | $type = $item->getType(); |
||
18 | $npfx = $item->getNpfx(); |
||
19 | $givn = $item->getGivn(); |
||
20 | $nick = $item->getNick(); |
||
21 | $spfx = $item->getSpfx(); |
||
22 | $surn = $item->getSurn(); |
||
23 | $nsfx = $item->getNsfx(); |
||
24 | |||
25 | // store asso |
||
26 | $key = [ |
||
27 | 'group'=> $group, |
||
28 | 'gid' => $group_id, |
||
29 | 'type' => $type, |
||
30 | 'name' => $name, |
||
31 | 'npfx' => $npfx, |
||
32 | 'givn' => $givn, |
||
33 | 'nick' => $nick, |
||
34 | 'spfx' => $spfx, |
||
35 | 'surn' => $surn, |
||
36 | 'nsfx' => $nsfx, |
||
37 | ]; |
||
38 | $data = [ |
||
39 | 'group'=> $group, |
||
40 | 'gid' => $group_id, |
||
41 | 'type' => $type, |
||
42 | 'name' => $name, |
||
43 | 'npfx' => $npfx, |
||
44 | 'givn' => $givn, |
||
45 | 'nick' => $nick, |
||
46 | 'spfx' => $spfx, |
||
47 | 'surn' => $surn, |
||
48 | 'nsfx' => $nsfx, |
||
49 | ]; |
||
50 | |||
51 | $record = PersonName::on($conn)->updateOrCreate($key, $data); |
||
52 | |||
53 | $_group = 'indi_name'; |
||
54 | $_gid = $record->id; |
||
55 | // store Note |
||
56 | $note = $item->getNote(); |
||
57 | if ($note && count($note) > 0) { |
||
|
|||
58 | foreach ($note as $_item) { |
||
59 | if ($_item) { |
||
60 | \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $_item, $_group, $_gid); |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | |||
65 | // store sourref |
||
66 | $sour = $item->getSour(); |
||
67 | if ($sour && count($sour) > 0) { |
||
68 | foreach ($sour as $_item) { |
||
69 | if ($_item) { |
||
70 | \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $_item, $_group, $_gid); |
||
71 | } |
||
72 | } |
||
73 | } |
||
74 | |||
75 | // store fone |
||
76 | $fone = $item->getFone(); |
||
77 | if ($fone != null) { |
||
78 | \FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Name\Fone::read($conn, $fone, $_group, $_gid); |
||
79 | } |
||
80 | |||
81 | // store romn |
||
82 | $romn = $item->getRomn(); |
||
83 | if ($romn != null) { |
||
84 | \FamilyTree365\LaravelGedcom\Utils\Importer\Indi\Name\Romn::read($conn, $romn, $_group, $_gid); |
||
85 | } |
||
88 |