Famc::convert()   A
last analyzed

Complexity

Conditions 6
Paths 5

Size

Total Lines 28
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 28
c 0
b 0
f 0
rs 9.2222
cc 6
nc 5
nop 2
1
<?php
2
/**
3
 * php-gedcom.
4
 *
5
 * php-gedcom is a library for parsing, manipulating, importing and exporting
6
 * GEDCOM 5.5 files in PHP 5.3+.
7
 *
8
 * @author          Xiang Ming <[email protected]>
9
 * @copyright       Copyright (c) 2010-2013, Xiang Ming
10
 * @license         MIT
11
 *
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace Gedcom\Writer\Indi;
16
17
class Famc
18
{
19
    /**
20
     * @param \Gedcom\Record\Indi\Famc $attr
21
     * @param int                      $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\Gedcom\Record\Indi\Famc &$famc, $level = 0)
26
    {
27
        $output = '';
28
        // NAME
29
        $_famc = $famc->getFams();
0 ignored issues
show
Bug introduced by
The method getFams() does not exist on Gedcom\Record\Indi\Famc. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

29
        /** @scrutinizer ignore-call */ 
30
        $_famc = $famc->getFams();
Loading history...
30
        if (empty($_fams)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $_fams does not exist. Did you maybe mean $_famc?
Loading history...
31
            return $output;
32
        }
33
        $output .= $level.' FAMC @'.$_famc."@\n";
0 ignored issues
show
Bug introduced by
Are you sure $_famc of type Gedcom\Record\Indi\Famc|mixed|null can be used in concatenation? ( Ignorable by Annotation )

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

33
        $output .= $level.' FAMC @'./** @scrutinizer ignore-type */ $_famc."@\n";
Loading history...
34
        // level up
35
        $level++;
36
37
        // PEDI
38
        $pedi = $famc->getPedi();
0 ignored issues
show
Bug introduced by
The method getPedi() does not exist on Gedcom\Record\Indi\Famc. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

38
        /** @scrutinizer ignore-call */ 
39
        $pedi = $famc->getPedi();
Loading history...
39
        if (!empty($pedi)) {
40
            $output .= $level.' PEDI '.$pedi."\n";
0 ignored issues
show
Bug introduced by
Are you sure $pedi of type Gedcom\Record\Indi\Famc|mixed can be used in concatenation? ( Ignorable by Annotation )

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

40
            $output .= $level.' PEDI './** @scrutinizer ignore-type */ $pedi."\n";
Loading history...
41
        }
42
43
        // note
44
        $note = $famc->getSour();
0 ignored issues
show
Bug introduced by
The method getSour() does not exist on Gedcom\Record\Indi\Famc. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

44
        /** @scrutinizer ignore-call */ 
45
        $note = $famc->getSour();
Loading history...
45
        if (!empty($note) && count($note) > 0) {
0 ignored issues
show
Bug introduced by
It seems like $note can also be of type Gedcom\Record\Indi\Famc; 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

45
        if (!empty($note) && count(/** @scrutinizer ignore-type */ $note) > 0) {
Loading history...
46
            foreach ($note as $item) {
47
                $_convert = \Gedcom\Writer\NoteRef::convert($item, $level);
48
                $output .= $_convert;
49
            }
50
        }
51
52
        return $output;
53
    }
54
}
55