Conditions | 17 |
Paths | 65 |
Total Lines | 60 |
Code Lines | 38 |
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 |
||
14 | public static function read($conn, $sour, $obje_ids = []) |
||
15 | { |
||
16 | if ($sour == null || is_array($sour)) { |
||
17 | return 0; |
||
18 | } |
||
19 | $auth = $sour->getAuth(); // string |
||
20 | $titl = $sour->getTitl(); // string |
||
21 | $abbr = $sour->getAbbr(); // string |
||
22 | $publ = $sour->getPubl(); // string |
||
23 | $rin = $sour->getRin(); // string |
||
24 | $text = $sour->getText(); // string |
||
25 | |||
26 | $record = Source::on($conn)->updateOrCreate( |
||
27 | compact('titl', 'rin', 'auth', 'text', 'publ', 'abbr'), |
||
28 | compact('titl', 'rin', 'auth', 'text', 'publ', 'abbr') |
||
29 | ); |
||
30 | |||
31 | $_group = 'sour'; |
||
32 | $_gid = $record->id; |
||
33 | |||
34 | $chan = $sour->getChan(); // Record/Chan |
||
35 | if ($chan !== null) { |
||
36 | \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid = 0); |
||
37 | } |
||
38 | $repo = $sour->getRepo(); // Repo |
||
39 | if ($repo !== null) { |
||
40 | \FamilyTree365\LaravelGedcom\Utils\Importer\Sour\Repo::read($conn, $repo, $_group, $_gid = 0); |
||
41 | } |
||
42 | $data = $sour->getData(); // object |
||
43 | if ($data !== null) { |
||
44 | \FamilyTree365\LaravelGedcom\Utils\Importer\Sour\Data::read($conn, $data, $_group, $_gid = 0); |
||
45 | } |
||
46 | $refn = $sour->getRefn(); // array |
||
47 | if ($refn && count($refn) > 0) { |
||
48 | foreach ($refn as $item) { |
||
49 | if ($item) { |
||
50 | \FamilyTree365\LaravelGedcom\Utils\Importer\Refn::read($conn, $item, $_group, $_gid = 0); |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 | |||
55 | $note = $sour->getNote(); // array |
||
56 | if ($note != null && count($note) > 0) { |
||
57 | foreach ($note as $item) { |
||
58 | \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid); |
||
59 | } |
||
60 | } |
||
61 | |||
62 | $obje = $sour->getObje(); // array |
||
63 | if ($obje && count($obje) > 0) { |
||
64 | foreach ($obje as $item) { |
||
65 | if ($item) { |
||
66 | \FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids); |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 | |||
71 | $sour = $sour->getSour(); // string id |
||
|
|||
72 | |||
73 | return $_gid; |
||
74 | } |
||
76 |