Conditions | 11 |
Paths | 64 |
Total Lines | 50 |
Code Lines | 26 |
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 |
||
24 | public static function convert(\Gedcom\Record\Fam\Slgs &$slgs, $level) |
||
25 | { |
||
26 | $output = ''; |
||
27 | $output .= $level." SLGS \n"; |
||
28 | |||
29 | // Level up |
||
30 | $level++; |
||
31 | |||
32 | // $STAT; |
||
33 | $stat = $slgs->getStat(); |
||
|
|||
34 | if (!empty($stat)) { |
||
35 | $output .= $level.' STAT '.$stat."\n"; |
||
36 | } |
||
37 | |||
38 | // $date; |
||
39 | $date = $slgs->getDate(); |
||
40 | if (!empty($date)) { |
||
41 | $output .= $level.' DATE '.$date."\n"; |
||
42 | } |
||
43 | |||
44 | // PLAC |
||
45 | $plac = $slgs->getPlac(); |
||
46 | if (!empty($plac)) { |
||
47 | $output .= $level.' PLAC '.$plac."\n"; |
||
48 | } |
||
49 | |||
50 | // $TEMP; |
||
51 | $temp = $slgs->getTemp(); |
||
52 | if (!empty($temp)) { |
||
53 | $output .= $level.' TEMP '.$temp."\n"; |
||
54 | } |
||
55 | |||
56 | // $sour = array(); |
||
57 | $sour = $slgs->getSour(); |
||
58 | if (!empty($sour) && count($sour) > 0) { |
||
59 | foreach ($sour as $item) { |
||
60 | $_convert = \Gedcom\Writer\SourRef::convert($item, $level); |
||
61 | $output .= $_convert; |
||
62 | } |
||
63 | } |
||
64 | // $note = array(); |
||
65 | $note = $slgs->getNote(); |
||
66 | if (!empty($note) && count($note) > 0) { |
||
67 | foreach ($note as $item) { |
||
68 | $_convert = \Gedcom\Writer\NoteRef::convert($item, $level); |
||
69 | $output .= $_convert; |
||
70 | } |
||
71 | } |
||
72 | |||
73 | return $output; |
||
74 | } |
||
76 |