Conditions | 20 |
Paths | 4097 |
Total Lines | 97 |
Code Lines | 53 |
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\Sour &$sour, $level) |
||
25 | { |
||
26 | $output = ''; |
||
27 | $_sour = $sour->getSour(); |
||
28 | if (empty($_sour)) { |
||
29 | return $output; |
||
30 | } else { |
||
31 | $output .= $level.' '.$_sour.' SOUR '."\n"; |
||
32 | } |
||
33 | // level up |
||
34 | $level++; |
||
35 | |||
36 | // TITL |
||
37 | $titl = $sour->getType(); |
||
|
|||
38 | if (!empty($type)) { |
||
39 | $output .= $level.' TITL '.$titl."\n"; |
||
40 | } |
||
41 | |||
42 | // RIN |
||
43 | $rin = $sour->getRin(); |
||
44 | if (!empty($rin)) { |
||
45 | $output .= $level.' RIN '.$rin."\n"; |
||
46 | } |
||
47 | |||
48 | // AUTH |
||
49 | $auth = $sour->getAuth(); |
||
50 | if (!empty($auth)) { |
||
51 | $output .= $level.' AUTH '.$auth."\n"; |
||
52 | } |
||
53 | |||
54 | // TEXT |
||
55 | $text = $sour->getText(); |
||
56 | if (!empty($text)) { |
||
57 | $output .= $level.' TEXT '.$text."\n"; |
||
58 | } |
||
59 | |||
60 | // PUBL |
||
61 | $publ = $sour->getPubl(); |
||
62 | if (!empty($publ)) { |
||
63 | $output .= $level.' PUBL '.$publ."\n"; |
||
64 | } |
||
65 | |||
66 | // ABBR |
||
67 | $abbr = $sour->getAbbr(); |
||
68 | if (!empty($abbr)) { |
||
69 | $output .= $level.' ABBR '.$abbr."\n"; |
||
70 | } |
||
71 | |||
72 | // REPO |
||
73 | $repo = $sour->getRepo(); |
||
74 | if (!empty($repo)) { |
||
75 | $_convert = \Gedcom\Writer\RepoRef::convert($repo, $level); |
||
76 | $output .= $_convert; |
||
77 | } |
||
78 | |||
79 | // NOTE array |
||
80 | $note = $sour->getNote(); |
||
81 | if (!empty($note) && count($note) > 0) { |
||
82 | foreach ($note as $item) { |
||
83 | $_convert = \Gedcom\Writer\NoteRef::convert($item, $level); |
||
84 | $output .= $_convert; |
||
85 | } |
||
86 | } |
||
87 | |||
88 | // DATA |
||
89 | $data = $sour->getData(); |
||
90 | if (!empty($data)) { |
||
91 | $_convert = \Gedcom\Writer\Sour\Data::convert($data, $level); |
||
92 | $output .= $_convert; |
||
93 | } |
||
94 | |||
95 | // OBJE array |
||
96 | $obje = $sour->getObje(); |
||
97 | if (!empty($obje) && count($obje) > 0) { |
||
98 | foreach ($obje as $item) { |
||
99 | $_convert = \Gedcom\Writer\ObjeRef::convert($item, $level); |
||
100 | $output .= $_convert; |
||
101 | } |
||
102 | } |
||
103 | |||
104 | // REFN array |
||
105 | $refn = $sour->getRefn(); |
||
106 | if (!empty($refn) && count($refn) > 0) { |
||
107 | foreach ($refn as $item) { |
||
108 | $_convert = \Gedcom\Writer\Refn::convert($item, $level); |
||
109 | $output .= $_convert; |
||
110 | } |
||
111 | } |
||
112 | |||
113 | // chan |
||
114 | $chan = $sour->getChan(); |
||
115 | if (!empty($chan)) { |
||
116 | $_convert = \Gedcom\Writer\Chan::convert($chan, $level); |
||
117 | $output .= $_convert; |
||
118 | } |
||
119 | |||
120 | return $output; |
||
121 | } |
||
123 |