| Conditions | 16 |
| Paths | 257 |
| Total Lines | 78 |
| Code Lines | 40 |
| 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\Obje &$obje) |
||
| 28 | { |
||
| 29 | $level = 0; |
||
| 30 | $output = ""; |
||
| 31 | $id = $obje->getId(); |
||
|
|
|||
| 32 | if($id){ |
||
| 33 | $output.=$level." ".$id." OBJE\n"; |
||
| 34 | }else{ |
||
| 35 | return $output; |
||
| 36 | } |
||
| 37 | |||
| 38 | // level up |
||
| 39 | $level++; |
||
| 40 | |||
| 41 | // FORM |
||
| 42 | $form = $obje->getName(); |
||
| 43 | if($form){ |
||
| 44 | $output.=$level." FORM ".$form."\n"; |
||
| 45 | } |
||
| 46 | |||
| 47 | // TITL |
||
| 48 | $titl = $obje->getTitl(); |
||
| 49 | if($titl){ |
||
| 50 | $output.=$level." TITL ".$titl."\n"; |
||
| 51 | } |
||
| 52 | |||
| 53 | // OBJE |
||
| 54 | // This is same as FORM |
||
| 55 | |||
| 56 | // RIN |
||
| 57 | $rin = $obje->getRin(); |
||
| 58 | if($rin){ |
||
| 59 | $output.=$level." RIN ".$rin."\n"; |
||
| 60 | } |
||
| 61 | |||
| 62 | // REFN |
||
| 63 | $refn = $obje->getRefn(); |
||
| 64 | if(!empty($refn) && count($refn) > 0) { |
||
| 65 | foreach($refn as $item){ |
||
| 66 | if($item){ |
||
| 67 | $_convert = \PhpGedcom\Writer\Refn::convert($item, $level); |
||
| 68 | $output.=$_convert; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | // BLOB |
||
| 74 | $blob = $obje->getBlob(); |
||
| 75 | if($blob){ |
||
| 76 | $output.=$level." BLOB ".$blob."\n"; |
||
| 77 | } |
||
| 78 | |||
| 79 | // NOTE |
||
| 80 | $note = $obje->getNote(); |
||
| 81 | if($note && count($note) > 0) { |
||
| 82 | foreach($note as $item){ |
||
| 83 | if($item){ |
||
| 84 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
| 85 | $output.=$_convert; |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | // CHAN |
||
| 91 | $chan = $obje->getChan(); |
||
| 92 | if($chan){ |
||
| 93 | $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
||
| 94 | $output.=$_convert; |
||
| 95 | } |
||
| 96 | |||
| 97 | // FILE |
||
| 98 | $file = $obje->getFile(); |
||
| 99 | if($file){ |
||
| 100 | $output.=$level." FILE ".$file."\n"; |
||
| 101 | } |
||
| 102 | |||
| 103 | // |
||
| 104 | return $output; |
||
| 105 | } |
||
| 107 |