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