Conditions | 10 |
Paths | 16 |
Total Lines | 52 |
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 |
||
16 | public static function read($conn, \Gedcom\Record\Indi\Lds $lds, $group = '', $group_id = 0, $type = '', $sour_ids = [], $obje_ids = []) |
||
17 | { |
||
18 | $stat = $lds->getStat(); |
||
19 | $date = $lds->getDate(); |
||
20 | $plac = $lds->getPlac(); |
||
21 | $temp = $lds->getTemp(); |
||
22 | |||
23 | $slgc_famc = ''; |
||
24 | if ($type == 'SLGC') { |
||
25 | $slgc_famc = $lds->getFamc(); |
||
26 | } |
||
27 | // store refn |
||
28 | $key = [ |
||
29 | 'group' => $group, |
||
30 | 'gid' => $group_id, |
||
31 | 'type' => $type, |
||
32 | 'stat' => $stat, |
||
33 | 'date' => $date, |
||
34 | 'plac' => $plac, |
||
35 | 'temp' => $temp, |
||
36 | 'slgc_famc' => $slgc_famc, |
||
37 | ]; |
||
38 | $data = [ |
||
39 | 'group' => $group, |
||
40 | 'gid' => $group_id, |
||
41 | 'type' => $type, |
||
42 | 'stat' => $stat, |
||
43 | 'date' => $date, |
||
44 | 'plac' => $plac, |
||
45 | 'temp' => $temp, |
||
46 | 'slgc_famc' => $slgc_famc, |
||
47 | ]; |
||
48 | $record = PersonLds::on($conn)->updateOrCreate($key, $data); |
||
49 | |||
50 | $_group = 'indi_lds'; |
||
51 | $_gid = $record->id; |
||
52 | // add sour |
||
53 | $sour = $lds->getSour(); |
||
54 | if ($sour && count($sour) > 0) { |
||
|
|||
55 | foreach ($sour as $item) { |
||
56 | if ($item) { |
||
57 | SourRef::read($conn, $item, $_group, $_gid, $sour_ids, $obje_ids); |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | |||
62 | // add note |
||
63 | $note = $lds->getNote(); |
||
64 | if ($note && count($note) > 0) { |
||
65 | foreach ($note as $item) { |
||
66 | if ($item) { |
||
67 | NoteRef::read($conn, $item, $_group, $_gid); |
||
68 | } |
||
73 |