otherFamRecord   A
last analyzed

Complexity

Total Complexity 34

Size/Duplication

Total Lines 103
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 64
c 1
b 0
f 0
dl 0
loc 103
rs 9.68
wmc 34

1 Method

Rating   Name   Duplication   Size   Complexity  
F insertFamilyData() 0 86 34
1
<?php
2
3
namespace FamilyTree365\LaravelGedcom\Utils;
4
5
use FamilyTree365\LaravelGedcom\Models\Family;
6
use FamilyTree365\LaravelGedcom\Models\Person;
7
use FamilyTree365\LaravelGedcom\Utils\Importer\Chan;
8
use FamilyTree365\LaravelGedcom\Utils\Importer\Fam\Even;
9
use FamilyTree365\LaravelGedcom\Utils\Importer\Fam\Slgs;
10
use FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef;
11
use FamilyTree365\LaravelGedcom\Utils\Importer\ObjeRef;
12
use FamilyTree365\LaravelGedcom\Utils\Importer\Refn;
13
use FamilyTree365\LaravelGedcom\Utils\Importer\SourRef;
14
use FamilyTree365\LaravelGedcom\Utils\Importer\Subm;
15
16
class otherFamRecord
17
{
18
    /**
19
     * Array of persons ID
20
     * key - old GEDCOM ID
21
     * value - new autoincrement ID.
22
     *
23
     * @var string
24
     */
25
    protected $persons_id = [];
26
    protected $subm_ids = [];
27
    protected $sour_ids = [];
28
    protected $obje_ids = [];
29
    protected $note_ids = [];
30
    protected $repo_ids = [];
31
    protected $conn = '';
32
33
    public static function insertFamilyData($conn, $persons_id, $families, $obje_ids, $sour_ids, $note_ids = [], $repo_ids = [])
0 ignored issues
show
Unused Code introduced by
The parameter $note_ids is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public static function insertFamilyData($conn, $persons_id, $families, $obje_ids, $sour_ids, /** @scrutinizer ignore-unused */ $note_ids = [], $repo_ids = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $repo_ids is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public static function insertFamilyData($conn, $persons_id, $families, $obje_ids, $sour_ids, $note_ids = [], /** @scrutinizer ignore-unused */ $repo_ids = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        foreach ($families as $family) {
36
            $g_id = $family->getId();
0 ignored issues
show
Unused Code introduced by
The assignment to $g_id is dead and can be removed.
Loading history...
37
            $husb = $family->getHusb();
38
            $wife = $family->getWife();
39
            $husband_id = $persons_id[$husb] ?? 0;
40
            $wife_id = $persons_id[$wife] ?? 0;
41
            $children = $family->getChil();
42
            $events = $family->getAllEven();
43
            $subm = $family->getSubm();
44
            $_slgs = $family->getSlgs();
45
            $_note = $family->getNote();
46
            $_obje = $family->getObje();
47
            $_sour = $family->getSour();
48
            $_refn = $family->getRefn();
49
            $chan = $family->getChan();
50
            $familie = Family::on($conn)->where('husband_id', $husband_id)->where('wife_id', $wife_id)->first();
51
            if ($children !== null) {
52
                foreach ($children as $child) {
53
                    if (isset($persons_id[$child])) {
54
                        $person = Person::on($conn)->find($persons_id[$child]);
55
                        $person->child_in_family_id = $familie->id;
56
                        $person->save();
57
                    }
58
                }
59
            }
60
61
            if ($events !== null && count($events) > 0) {
62
                foreach ($events as $item) {
63
                    if ($item) {
64
                        Even::read($conn, $item, $familie, $obje_ids);
65
                    }
66
                    // $date = $getDate($item->getDate());
67
                    // $place = $getPlace($item->getPlac());
68
                    // $family->addEvent($item->getType(), $date, $place);
69
                }
70
            }
71
            $_group = 'fam';
72
            if ($familie == null) {
73
                $_gid = 0;
74
            } else {
75
                $_gid = $familie->id;
76
            }
77
            if ($_note != null && count($_note) > 0) {
78
                foreach ($_note as $item) {
79
                    NoteRef::read($conn, $item, $_group, $_gid);
80
                }
81
            }
82
            if ($_obje && count($_obje) > 0) {
83
                foreach ($_obje as $item) {
84
                    if ($item) {
85
                        ObjeRef::read($conn, $item, $_group, $_gid, $obje_ids);
86
                    }
87
                }
88
            }
89
            if ($_refn && count($_refn) > 0) {
90
                foreach ($_refn as $item) {
91
                    if ($item) {
92
                        Refn::read($conn, $item, $_group, $_gid);
93
                    }
94
                }
95
            }
96
            if ($_sour && count($_sour) > 0) {
97
                foreach ($_sour as $item) {
98
                    if ($item) {
99
                        SourRef::read($conn, $item, $_group, $_gid, $sour_ids, $obje_ids);
100
                    }
101
                }
102
            }
103
            if ($_slgs && count($_slgs) > 0) {
104
                foreach ($_slgs as $item) {
105
                    if ($item) {
106
                        Slgs::read($conn, $item, $familie);
107
                    }
108
                }
109
            }
110
            if ($subm && count($subm) > 0) {
111
                foreach ($subm as $item) {
112
                    if ($item) {
113
                        Subm::read($conn, $item, $_group, $_gid, $obje_ids);
114
                    }
115
                }
116
            }
117
            if ($chan) {
118
                Chan::read($conn, $chan, 'family', $familie->id);
119
            }
120
        }
121
    }
122
}
123