Subn   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 23
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B read() 0 31 8
1
<?php
2
3
namespace FamilyTree365\LaravelGedcom\Utils\Importer;
4
5
use FamilyTree365\LaravelGedcom\Models\Subn as MSubn;
6
7
class Subn
8
{
9
    /**
10
     * Gedcom\Record\Subn $subn
11
     * String $group
12
     * Integer $group_id.
13
     */
14
    public static function read($conn, $subn, $subm_ids)
15
    {
16
        if ($subn == null || is_array($subn)) {
17
            return;
18
        }
19
        $_subm = $subn->getSubm();
20
        $subm = null;
21
        if (isset($subm_ids[$subm])) {
22
            $subm = $subm_ids[$_subm];
23
        }
24
        $famf = $subn->getFamf();
25
        $temp = $subn->getTemp();
26
        $ance = $subn->getAnce();
27
        $desc = $subn->getDesc();
28
        $ordi = $subn->getOrdi();
29
        $rin = $subn->getRin();
30
        $record = MSubn::on($conn)->updateOrCreate(compact('subm', 'famf', 'temp', 'ance', 'desc', 'ordi', 'rin'), compact('subm', 'famf', 'temp', 'ance', 'desc', 'ordi', 'rin'));
31
32
        $_group = 'subn';
33
        $_gid = $record->id;
34
35
        $note = $subn->getNote();  // array ---
36
37
        if ($note != null && count($note) > 0) {
38
            foreach ($note as $item) {
39
                \FamilyTree365\LaravelGedcom\Utils\Importer\NoteRef::read($conn, $item, $_group, $_gid);
40
            }
41
        }
42
        $chan = $subn->getChan() ?? null; // Record\Chan---
43
        if ($chan !== null) {
44
            \FamilyTree365\LaravelGedcom\Utils\Importer\Chan::read($conn, $chan, $_group, $_gid);
45
        }
46
    }
47
}
48