Conditions | 10 |
Paths | 128 |
Total Lines | 46 |
Code Lines | 28 |
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\SourRef &$sour, $level) |
||
26 | { |
||
27 | $output = ''; |
||
28 | $_sour = $sour->getSour(); |
||
|
|||
29 | if (!empty($_sour)) { |
||
30 | $output .= $level.' SOUR '.$_sour."\n"; |
||
31 | } |
||
32 | $level++; |
||
33 | // protected $_text = null; |
||
34 | $_text = $sour->getText(); |
||
35 | if (!empty($_text)) { |
||
36 | $output .= $level.' TEXT '.$_text."\n"; |
||
37 | } |
||
38 | // protected $_note = array(); |
||
39 | $note = $sour->getNote(); |
||
40 | if ($note && count($note) > 0) { |
||
41 | foreach ($note as $item) { |
||
42 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
43 | $output .= $_convert; |
||
44 | } |
||
45 | } |
||
46 | // protected $_data = null; |
||
47 | $_data = $sour->getData(); |
||
48 | if ($_data) { |
||
49 | $_convert = \PhpGedcom\Writer\Sour\Data::convert($_data, $level); |
||
50 | $output .= $_convert; |
||
51 | } |
||
52 | // protected $_page setPage |
||
53 | $_page = $sour->getPage(); |
||
54 | if (!empty($_page)) { |
||
55 | $output .= $level.' PAGE '.$_page."\n"; |
||
56 | } |
||
57 | // protected $_even = null; |
||
58 | $_even = $sour->getData(); |
||
59 | if ($_even) { |
||
60 | $_convert = \PhpGedcom\Writer\SourRef\Even::convert($_even, $level); |
||
61 | $output .= $_convert; |
||
62 | } |
||
63 | // protected $_quay |
||
64 | $_quay = $sour->getQuay(); |
||
65 | if (!empty($_quay)) { |
||
66 | $output .= $level.' QUAY '.$_quay."\n"; |
||
67 | } |
||
68 | // protected $_obje = array(); |
||
69 | // This is not defined in parser. |
||
70 | return $output; |
||
71 | } |
||
73 |