Passed
Push — master ( 6f3564...5d9325 )
by Curtis
12:40
created

Slgs   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 11

1 Method

Rating   Name   Duplication   Size   Complexity  
B read() 0 53 11
1
<?php
2
3
namespace FamilyTree365\LaravelGedcom\Utils\Exporter\Fam;
4
5
use FamilyTree365\LaravelGedcom\Models\FamilySlgs;
6
use Throwable;
7
8
class Slgs
9
{
10
    /**
11
     * Array of persons ID
12
     * key - old GEDCOM ID
13
     * value - new autoincrement ID.
14
     *
15
     * @var string
16
     */
17
    public static function read($conn, $slgs, $fam)
18
    {
19
        try
20
        {
21
            if ($slgs == null || $fam === null) {
22
                return;
23
            }
24
25
            $stat = $slgs->getStat();
26
            $date = $slgs->getDate();
27
            $plac = $slgs->getPlac();
28
            $temp = $slgs->getTemp();
29
30
            $key = [
31
                'family_id'=> $fam->id,
32
                'stat'     => $stat,
33
                'date'     => $date,
34
                'plac'     => $plac,
35
                'temp'     => $temp,
36
            ];
37
            $data = [
38
                'family_id'=> $fam->id,
39
                'stat'     => $stat,
40
                'date'     => $date,
41
                'plac'     => $plac,
42
                'temp'     => $temp,
43
            ];
44
45
            $record = FamilySlgs::on($conn)->updateOrCreate($key, $data);
46
47
            $_group = 'fam_slgs';
48
            $_gid = $record->id;
49
50
            // array
51
            $sour = $slgs->getSour();
52
            if ($sour && count($sour) > 0) {
53
                foreach ($sour as $item) {
54
                    if ($item) {
55
                        \FamilyTree365\LaravelGedcom\Utils\Importer\SourRef::read($conn, $item, $_group, $_gid);
56
                    }
57
                }
58
            }
59
60
            $note = $slgs->getNote();
61
            if ($note && count($note) > 0) {
62
                foreach ($note as $item) {
63
                    \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid);
64
                }
65
            }
66
        }
67
        catch(Throwable $e)
68
        {
69
            report($e);
0 ignored issues
show
Bug introduced by
The function report was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

69
            /** @scrutinizer ignore-call */ 
70
            report($e);
Loading history...
70
        }
71
    }
72
}
73