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

Chan   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A read() 0 19 5
1
<?php
2
3
namespace FamilyTree365\LaravelGedcom\Utils\Exporter;
4
5
use FamilyTree365\LaravelGedcom\Models\Chan as MChan;
6
7
class Chan
8
{
9
    /**
10
     * Gedcom\Record\Chan $chan
11
     * String $group
12
     * Integer $group_id.
13
     */
14
    public static function read($conn, \Gedcom\Record\Chan $chan, $group = '', $group_id = 0)
15
    {
16
        $date = $chan->getDate();
17
        $time = $chan->getTime();
18
19
        // store chan
20
        $key = ['group'=>$group, 'gid'=>$group_id, 'date'=>$date, 'time'=>$time];
21
        $data = ['group'=>$group, 'gid'=>$group_id,  'date'=>$date, 'time'=>$time];
22
        $record = MChan::on($conn)->updateOrCreate($key, $data);
23
24
        // store Sources of Note
25
        $_group = 'chan';
26
        $_gid = $record->id;
27
        // SourRef array
28
        $note = $chan->getNote();
29
        if ($note && count($note) > 0) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $note of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
30
            foreach ($note as $item) {
31
                if ($item) {
32
                    NoteRef::read($conn, $item, $_group, $_gid);
33
                }
34
            }
35
        }
36
    }
37
}
38