Sour   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 54
dl 0
loc 105
rs 10
c 0
b 0
f 0
wmc 20

1 Method

Rating   Name   Duplication   Size   Complexity  
F convert() 0 97 20
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 Sour
18
{
19
    /**
20
     * @param \PhpGedcom\Record\Sour $sour
21
     * @param int                    $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\PhpGedcom\Record\Sour &$sour, $level)
26
    {
27
        $output = '';
28
        $_sour = $sour->getSour();
29
        if (empty($_sour)) {
30
            return $output;
31
        } else {
32
            $output .= $level.' '.$_sour.' SOUR '."\n";
33
        }
34
        // level up
35
        $level++;
36
37
        // TITL
38
        $titl = $sour->getType();
0 ignored issues
show
Bug introduced by
The method getType() does not exist on PhpGedcom\Record\Sour. 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
        $titl = $sour->getType();
Loading history...
39
        if (!empty($type)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $type seems to never exist and therefore empty should always be true.
Loading history...
40
            $output .= $level.' TITL '.$titl."\n";
0 ignored issues
show
Bug introduced by
Are you sure $titl of type PhpGedcom\Record\Sour|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

40
            $output .= $level.' TITL './** @scrutinizer ignore-type */ $titl."\n";
Loading history...
41
        }
42
43
        // RIN
44
        $rin = $sour->getRin();
45
        if (!empty($rin)) {
46
            $output .= $level.' RIN '.$rin."\n";
47
        }
48
49
        // AUTH
50
        $auth = $sour->getAuth();
51
        if (!empty($auth)) {
52
            $output .= $level.' AUTH '.$auth."\n";
53
        }
54
55
        // TEXT
56
        $text = $sour->getText();
57
        if (!empty($text)) {
58
            $output .= $level.' TEXT '.$text."\n";
59
        }
60
61
        // PUBL
62
        $publ = $sour->getPubl();
63
        if (!empty($publ)) {
64
            $output .= $level.' PUBL '.$publ."\n";
65
        }
66
67
        // ABBR
68
        $abbr = $sour->getAbbr();
69
        if (!empty($abbr)) {
70
            $output .= $level.' ABBR '.$abbr."\n";
71
        }
72
73
        // REPO
74
        $repo = $sour->getRepo();
75
        if (!empty($repo)) {
76
            $_convert = \PhpGedcom\Writer\RepoRef::convert($repo, $level);
0 ignored issues
show
Bug introduced by
$repo of type PhpGedcom\Record\Repo is incompatible with the type PhpGedcom\Record\RepoRef expected by parameter $reporef of PhpGedcom\Writer\RepoRef::convert(). ( Ignorable by Annotation )

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

76
            $_convert = \PhpGedcom\Writer\RepoRef::convert(/** @scrutinizer ignore-type */ $repo, $level);
Loading history...
77
            $output .= $_convert;
78
        }
79
80
        // NOTE array
81
        $note = $sour->getNote();
82
        if (!empty($note) && count($note) > 0) {
83
            foreach ($note as $item) {
84
                $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level);
85
                $output .= $_convert;
86
            }
87
        }
88
89
        // DATA
90
        $data = $sour->getData();
91
        if (!empty($data)) {
92
            $_convert = \PhpGedcom\Writer\Sour\Data::convert($data, $level);
0 ignored issues
show
Bug introduced by
$data of type string is incompatible with the type PhpGedcom\Record\Sour\Data expected by parameter $data of PhpGedcom\Writer\Sour\Data::convert(). ( Ignorable by Annotation )

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

92
            $_convert = \PhpGedcom\Writer\Sour\Data::convert(/** @scrutinizer ignore-type */ $data, $level);
Loading history...
93
            $output .= $_convert;
94
        }
95
96
        // OBJE array
97
        $obje = $sour->getObje();
98
        if (!empty($obje) && count($obje) > 0) {
99
            foreach ($obje as $item) {
100
                $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level);
101
                $output .= $_convert;
102
            }
103
        }
104
105
        // REFN array
106
        $refn = $sour->getRefn();
107
        if (!empty($refn) && count($refn) > 0) {
108
            foreach ($refn as $item) {
109
                $_convert = \PhpGedcom\Writer\Refn::convert($item, $level);
110
                $output .= $_convert;
111
            }
112
        }
113
114
        // chan
115
        $chan = $sour->getChan();
116
        if (!empty($chan)) {
117
            $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level);
118
            $output .= $_convert;
119
        }
120
121
        return $output;
122
    }
123
}
124