Subm   A
last analyzed

Complexity

Total Complexity 21

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 21
eloc 49
dl 0
loc 93
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
F convert() 0 85 21
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;
16
17
class Subm
18
{
19
    /**
20
     * @param \Gedcom\Record\Subm $note
21
     * @param int                 $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\Gedcom\Record\Subm &$subm)
26
    {
27
        $level = 0;
28
        $output = '';
29
        $_subm = $subm->getSubn();
0 ignored issues
show
Bug introduced by
The method getSubn() does not exist on Gedcom\Record\Subm. 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
        $_subm = $subm->getSubn();
Loading history...
30
        if (empty($_subm)) {
31
            return $output;
32
        } else {
33
            $output .= $level.' '.$_subm.' SUBM '."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_subm of type Gedcom\Record\Subm|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

33
            $output .= $level.' './** @scrutinizer ignore-type */ $_subm.' SUBM '."\n";
Loading history...
34
        }
35
        // level up
36
        $level++;
37
38
        // NAME
39
        $name = $subm->getName();
40
        if (!empty($name)) {
41
            $output .= $level.' NAME '.$name."\n";
42
        }
43
        // $chan
44
        $chan = $subm->getChan();
45
        if ($chan) {
0 ignored issues
show
introduced by
$chan is of type Gedcom\Record\Chan, thus it always evaluated to true.
Loading history...
46
            $_convert = \Gedcom\Writer\Chan::convert($chan, $level);
47
            $output .= $_convert;
48
        }
49
50
        // $addr
51
        $addr = $subm->getAddr();
52
        if ($addr) {
0 ignored issues
show
introduced by
$addr is of type Gedcom\Record\Addr, thus it always evaluated to true.
Loading history...
53
            $_convert = \Gedcom\Writer\Addr::convert($addr, $level);
54
            $output .= $_convert;
55
        }
56
57
        // $rin
58
        $rin = $subm->getRin();
59
        if (!empty($rin)) {
60
            $output .= $level.' RIN '.$rin."\n";
61
        }
62
63
        // $rfn
64
        $rfn = $subm->getRfn();
65
        if (!empty($rfn)) {
66
            $output .= $level.' RFN '.$rfn."\n";
67
        }
68
69
        // $lang = array()
70
        $langs = $subm->getLang();
71
        if (!empty($langs) && count($langs) > 0) {
72
            foreach ($langs as $item) {
73
                if ($item) {
74
                    $_convert = $level.' LANG '.$item."\n";
75
                    $output .= $_convert;
76
                }
77
            }
78
        }
79
80
        // $phon = array()
81
        $phon = $subm->getLang();
82
        if (!empty($phon) && count($phon) > 0) {
83
            foreach ($phon as $item) {
84
                if ($item) {
85
                    $_convert = \Gedcom\Writer\Phon::convert($item, $level);
86
                    $output .= $_convert;
87
                }
88
            }
89
        }
90
91
        // $obje = array()
92
        $obje = $subm->getObje();
93
        if (!empty($obje) && count($obje) > 0) {
94
            foreach ($obje as $item) {
95
                $_convert = \Gedcom\Writer\ObjeRef::convert($item, $level);
96
                $output .= $_convert;
97
            }
98
        }
99
100
        // note
101
        $note = $subm->getNote();
102
        if (!empty($note) && count($note) > 0) {
103
            foreach ($note as $item) {
104
                $_convert = \Gedcom\Writer\NoteRef::convert($item, $level);
105
                $output .= $_convert;
106
            }
107
        }
108
109
        return $output;
110
    }
111
}
112