| Conditions | 10 |
| Paths | 32 |
| Total Lines | 44 |
| Code Lines | 23 |
| 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\Data &$data, $level = 0) |
||
| 26 | { |
||
| 27 | $output = ''; |
||
|
|
|||
| 28 | |||
| 29 | $output = $level." DATA\n"; |
||
| 30 | $level++; |
||
| 31 | |||
| 32 | // $_date; |
||
| 33 | $date = $data->getDate(); |
||
| 34 | if (!empty($date)) { |
||
| 35 | $output .= $level.' DATE '.$date."\n"; |
||
| 36 | } |
||
| 37 | |||
| 38 | // $_agnc AGNC |
||
| 39 | $_agnc = $data->getAgnc(); |
||
| 40 | if (!empty($_agnc)) { |
||
| 41 | $output .= $level.' AGNC '.$_agnc."\n"; |
||
| 42 | } |
||
| 43 | |||
| 44 | // $_text |
||
| 45 | $_text = $data->getText(); |
||
| 46 | if (!empty($_text)) { |
||
| 47 | $output .= $level.' TEXT '.$_text."\n"; |
||
| 48 | } |
||
| 49 | |||
| 50 | // $_note |
||
| 51 | $note = $data->getNote(); |
||
| 52 | if ($note && count($note) > 0) { |
||
| 53 | foreach ($note as $item) { |
||
| 54 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
| 55 | $output .= $_convert; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | |||
| 59 | // $_even |
||
| 60 | $_even = $data->getEven(); |
||
| 61 | if ($_even && count($_even) > 0) { |
||
| 62 | foreach ($_even as $item) { |
||
| 63 | $_convert = \PhpGedcom\Writer\Sour\Data\Even::convert($item, $level); |
||
| 64 | $output .= $_convert; |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | return $output; |
||
| 69 | } |
||
| 71 |