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