RepoRef   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 9

1 Method

Rating   Name   Duplication   Size   Complexity  
B read() 0 31 9
1
<?php
2
3
namespace FamilyTree365\LaravelGedcom\Utils\Importer;
4
5
use FamilyTree365\LaravelGedcom\Models\Repository;
6
7
class RepoRef
8
{
9
    /**
10
     * Gedcom\Record\RepoRef $reporef
11
     * String $group
12
     * Integer $group_id.
13
     */
14
    public static function read($conn, \Gedcom\Record\RepoRef $reporef, $group = '', $group_id = 0)
15
    {
16
        if ($reporef == null) {
17
            return;
18
        }
19
        $repo = $reporef->getRepo();
20
        // store Source
21
        $key = ['group'=>$group, 'gid'=>$group_id, 'repo' => $repo];
22
        $data = [
23
            'group'=> $group,
24
            'gid'  => $group_id,
25
            'repo' => $repo,
26
        ];
27
        $record = Repository::on($conn)->updateOrCreate($key, $data);
28
29
        $_group = 'reporef';
30
        $_gid = $record->id;
31
        // store Note
32
        $notes = $reporef->getNote();
33
        if ($notes && count($notes) > 0) {
0 ignored issues
show
Bug introduced by
It seems like $notes can also be of type Gedcom\Record\RepoRef; however, parameter $value of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

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

33
        if ($notes && count(/** @scrutinizer ignore-type */ $notes) > 0) {
Loading history...
34
            foreach ($notes as $item) {
35
                NoteRef::read($conn, $item, $_group, $_gid);
36
            }
37
        }
38
39
        // store Caln
40
        $caln = $reporef->getCaln();
41
        if ($caln && count($caln) > 0) {
42
            foreach ($caln as $item) {
43
                if ($item) {
44
                    Caln::read($conn, $item, $_group, $_gid);
45
                }
46
            }
47
        }
48
    }
49
}
50