| Conditions | 11 |
| Paths | 18 |
| Total Lines | 55 |
| Code Lines | 34 |
| 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 |
||
| 16 | public static function read($conn, \Gedcom\Record\SourRef $sourref, $group = '', $group_id = 0, $sour_ids = [], $obje_ids = []) |
||
| 17 | { |
||
| 18 | if ($sourref == null) { |
||
| 19 | return; |
||
| 20 | } |
||
| 21 | |||
| 22 | $sour = $sourref->getSour(); |
||
| 23 | if (!isset($sour_ids[$sour])) { |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | $sour_id = $sour_ids[$sour]; |
||
| 27 | $text = $sourref->getText(); |
||
| 28 | $quay = $sourref->getQuay(); |
||
| 29 | $page = $sourref->getPage(); |
||
| 30 | |||
| 31 | // store Source |
||
| 32 | $key = ['group'=>$group, 'gid'=>$group_id, 'sour_id'=>$sour_id]; |
||
| 33 | $data = [ |
||
| 34 | 'group' => $group, |
||
| 35 | 'gid' => $group_id, |
||
| 36 | 'sour_id'=> $sour_id, |
||
| 37 | 'text' => $text, |
||
| 38 | 'quay' => $quay, |
||
| 39 | 'page' => $page, |
||
| 40 | ]; |
||
| 41 | $record = SourceRef::on($conn)->updateOrCreate($key, $data); |
||
| 42 | |||
| 43 | $_group = 'sourref'; |
||
| 44 | $_gid = $record->id; |
||
| 45 | // store MediaObje |
||
| 46 | $objes = $sourref->getObje(); |
||
| 47 | if ($objes && count($objes) > 0) { |
||
|
|
|||
| 48 | foreach ($objes as $item) { |
||
| 49 | ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | // store Note |
||
| 54 | $notes = $sourref->getNote(); |
||
| 55 | if ($notes && count($notes) > 0) { |
||
| 56 | foreach ($notes as $item) { |
||
| 57 | NoteRef::read($conn, $item, $_group, $_gid); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | // store Data |
||
| 62 | $data = $sourref->getData(); |
||
| 63 | if ($data) { |
||
| 64 | Data::read($conn, $data, $_group, $_gid); |
||
| 65 | } |
||
| 66 | |||
| 67 | // store \Gedcom\Record\SourRef\Even |
||
| 68 | $even = $sourref->getEven(); |
||
| 69 | if ($even) { |
||
| 70 | Even::read($conn, $even, $_group, $_gid); |
||
| 71 | } |
||
| 74 |