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