ObjeRef::convert()   B
last analyzed

Complexity

Conditions 8
Paths 32

Size

Total Lines 41
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 22
nc 32
nop 2
dl 0
loc 41
rs 8.4444
c 0
b 0
f 0
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 PhpGedcom\Writer;
16
17
class ObjeRef
18
{
19
    /**
20
     * @param \PhpGedcom\Record\ObjeRef $note
21
     * @param int                       $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\PhpGedcom\Record\ObjeRef &$obje, $level)
26
    {
27
        $output = '';
28
29
        // $_note
30
        $_obje = $obje->getObje();
0 ignored issues
show
Bug introduced by
The method getObje() does not exist on PhpGedcom\Record\ObjeRef. 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

30
        /** @scrutinizer ignore-call */ 
31
        $_obje = $obje->getObje();
Loading history...
31
        if (!empty($_note)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $_note seems to never exist and therefore empty should always be true.
Loading history...
32
            $output .= $level.' OBJE '.$_obje."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_obje of type PhpGedcom\Record\ObjeRef|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

32
            $output .= $level.' OBJE './** @scrutinizer ignore-type */ $_obje."\n";
Loading history...
33
        } else {
34
            $output .= $level." OBJE \n";
35
        }
36
37
        $level++;
38
        // _form
39
        $_form = $obje->getForm();
0 ignored issues
show
Bug introduced by
The method getForm() does not exist on PhpGedcom\Record\ObjeRef. 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

39
        /** @scrutinizer ignore-call */ 
40
        $_form = $obje->getForm();
Loading history...
40
        if (!empty($_form)) {
41
            $output .= $level.' FORM '.$_form."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_form of type PhpGedcom\Record\ObjeRef|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

41
            $output .= $level.' FORM './** @scrutinizer ignore-type */ $_form."\n";
Loading history...
42
        }
43
44
        // _titl
45
        $_titl = $obje->getTitl();
0 ignored issues
show
Bug introduced by
The method getTitl() does not exist on PhpGedcom\Record\ObjeRef. 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

45
        /** @scrutinizer ignore-call */ 
46
        $_titl = $obje->getTitl();
Loading history...
46
        if (!empty($_titl)) {
47
            $output .= $level.' TITL '.$_titl."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_titl of type PhpGedcom\Record\ObjeRef|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

47
            $output .= $level.' TITL './** @scrutinizer ignore-type */ $_titl."\n";
Loading history...
48
        }
49
50
        // _file
51
        $_file = $obje->getFile();
0 ignored issues
show
Bug introduced by
The method getFile() does not exist on PhpGedcom\Record\ObjeRef. 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

51
        /** @scrutinizer ignore-call */ 
52
        $_file = $obje->getFile();
Loading history...
52
        if (!empty($_file)) {
53
            $output .= $level.' FILE '.$_file."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_file of type PhpGedcom\Record\ObjeRef|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

53
            $output .= $level.' FILE './** @scrutinizer ignore-type */ $_file."\n";
Loading history...
54
        }
55
56
        // $_note = array()
57
        $_note = $obje->getNote();
0 ignored issues
show
Bug introduced by
The method getNote() does not exist on PhpGedcom\Record\ObjeRef. 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

57
        /** @scrutinizer ignore-call */ 
58
        $_note = $obje->getNote();
Loading history...
58
        if (!empty($_note) && count($_note) > 0) {
0 ignored issues
show
Bug introduced by
It seems like $_note can also be of type PhpGedcom\Record\ObjeRef; however, parameter $var 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

58
        if (!empty($_note) && count(/** @scrutinizer ignore-type */ $_note) > 0) {
Loading history...
59
            foreach ($_note as $item) {
60
                $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level);
61
                $output .= $_convert;
62
            }
63
        }
64
65
        return $output;
66
    }
67
}
68