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