Even::convert()   F
last analyzed

Complexity

Conditions 23
Paths 8193

Size

Total Lines 108
Code Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 23
eloc 59
nc 8193
nop 2
dl 0
loc 108
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\Fam;
16
17
class Even
18
{
19
    /**
20
     * @param \PhpGedcom\Record\Fam\Even $even
21
     * @param int                        $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\PhpGedcom\Record\Fam\Even &$even, $level)
26
    {
27
        $output = '';
28
29
        // $type;
30
        $type = $even->getType();
31
        if (!empty($type)) {
32
            $output .= $level.' '.$type."\n";
33
        } else {
34
            return $output;
35
        }
36
        $level++;
37
38
        // $type;
39
        $type = $even->getType();
40
        if (!empty($type)) {
41
            $output .= $level.' TYPE '.$type."\n";
42
        }
43
44
        // $date;
45
        $date = $even->getDate();
46
        if (!empty($date)) {
47
            $output .= $level.' DATE '.$date."\n";
0 ignored issues
show
Bug introduced by
Are you sure $date of type PhpGedcom\Record\Date can be used in concatenation? Consider adding a __toString()-method. ( 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.' DATE './** @scrutinizer ignore-type */ $date."\n";
Loading history...
48
        }
49
50
        // Plac
51
        $plac = $even->getPlac();
52
        if (!empty($plac)) {
53
            $_convert = \PhpGedcom\Writer\Indi\Even\Plac::convert($plac, $level);
0 ignored issues
show
Bug introduced by
$plac of type string is incompatible with the type PhpGedcom\Record\Indi\Even\Plac expected by parameter $plac of PhpGedcom\Writer\Indi\Even\Plac::convert(). ( Ignorable by Annotation )

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

53
            $_convert = \PhpGedcom\Writer\Indi\Even\Plac::convert(/** @scrutinizer ignore-type */ $plac, $level);
Loading history...
54
            $output .= $_convert;
55
        }
56
57
        // $caus;
58
        $caus = $even->getCaus();
0 ignored issues
show
Bug introduced by
The method getCaus() does not exist on PhpGedcom\Record\Fam\Even. 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

58
        /** @scrutinizer ignore-call */ 
59
        $caus = $even->getCaus();
Loading history...
59
        if (!empty($caus)) {
60
            $output .= $level.' CAUS '.$caus."\n";
0 ignored issues
show
Bug introduced by
Are you sure $caus of type PhpGedcom\Record\Fam\Even|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

60
            $output .= $level.' CAUS './** @scrutinizer ignore-type */ $caus."\n";
Loading history...
61
        }
62
63
        // $age;
64
        $age = $even->getAge();
0 ignored issues
show
Bug introduced by
The method getAge() does not exist on PhpGedcom\Record\Fam\Even. 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

64
        /** @scrutinizer ignore-call */ 
65
        $age = $even->getAge();
Loading history...
65
        if (!empty($age)) {
66
            $output .= $level.' AGE '.$age."\n";
0 ignored issues
show
Bug introduced by
Are you sure $age of type PhpGedcom\Record\Fam\Even|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

66
            $output .= $level.' AGE './** @scrutinizer ignore-type */ $age."\n";
Loading history...
67
        }
68
69
        // $addr
70
        $addr = $even->getAddr();
0 ignored issues
show
Bug introduced by
The method getAddr() does not exist on PhpGedcom\Record\Fam\Even. 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

70
        /** @scrutinizer ignore-call */ 
71
        $addr = $even->getAddr();
Loading history...
71
        if (!empty($addr)) {
72
            $_convert = \PhpGedcom\Writer\Addr::convert($addr, $level);
0 ignored issues
show
Bug introduced by
It seems like $addr can also be of type PhpGedcom\Record\Fam\Even; however, parameter $addr of PhpGedcom\Writer\Addr::convert() does only seem to accept PhpGedcom\Record\Addr, 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

72
            $_convert = \PhpGedcom\Writer\Addr::convert(/** @scrutinizer ignore-type */ $addr, $level);
Loading history...
73
            $output .= $_convert;
74
        }
75
76
        // $phon = array()
77
        $phon = $even->getPhon();
0 ignored issues
show
Bug introduced by
The method getPhon() does not exist on PhpGedcom\Record\Fam\Even. 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

77
        /** @scrutinizer ignore-call */ 
78
        $phon = $even->getPhon();
Loading history...
78
        if (!empty($phon) && count($phon) > 0) {
0 ignored issues
show
Bug introduced by
It seems like $phon can also be of type PhpGedcom\Record\Fam\Even; 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

78
        if (!empty($phon) && count(/** @scrutinizer ignore-type */ $phon) > 0) {
Loading history...
79
            foreach ($phon as $item) {
80
                $_convert = \PhpGedcom\Writer\Phon::convert($item, $level);
81
                $output .= $_convert;
82
            }
83
        }
84
        // $agnc
85
        $agnc = $even->getAgnc();
0 ignored issues
show
Bug introduced by
The method getAgnc() does not exist on PhpGedcom\Record\Fam\Even. 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

85
        /** @scrutinizer ignore-call */ 
86
        $agnc = $even->getAgnc();
Loading history...
86
        if (!empty($agnc)) {
87
            $output .= $level.' AGNC '.$agnc."\n";
0 ignored issues
show
Bug introduced by
Are you sure $agnc of type PhpGedcom\Record\Fam\Even|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

87
            $output .= $level.' AGNC './** @scrutinizer ignore-type */ $agnc."\n";
Loading history...
88
        }
89
90
        // HUSB
91
        $husb = $even->getHusb();
0 ignored issues
show
Bug introduced by
The method getHusb() does not exist on PhpGedcom\Record\Fam\Even. 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

91
        /** @scrutinizer ignore-call */ 
92
        $husb = $even->getHusb();
Loading history...
92
        if (!empty($husb)) {
93
            $_convert = \PhpGedcom\Writer\Fam\Even\Husb::convert($husb, $level);
0 ignored issues
show
Bug introduced by
It seems like $husb can also be of type PhpGedcom\Record\Fam\Even; however, parameter $husb of PhpGedcom\Writer\Fam\Even\Husb::convert() does only seem to accept PhpGedcom\Record\Fam\Even\Husb, 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

93
            $_convert = \PhpGedcom\Writer\Fam\Even\Husb::convert(/** @scrutinizer ignore-type */ $husb, $level);
Loading history...
94
            $output .= $_convert;
95
        }
96
97
        // WIFE
98
        $wife = $even->getWife();
0 ignored issues
show
Bug introduced by
The method getWife() does not exist on PhpGedcom\Record\Fam\Even. 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

98
        /** @scrutinizer ignore-call */ 
99
        $wife = $even->getWife();
Loading history...
99
        if (!empty($wife)) {
100
            $_convert = \PhpGedcom\Writer\Fam\Even\Wife::convert($wife, $level);
0 ignored issues
show
Bug introduced by
It seems like $wife can also be of type PhpGedcom\Record\Fam\Even; however, parameter $wife of PhpGedcom\Writer\Fam\Even\Wife::convert() does only seem to accept PhpGedcom\Record\Fam\Even\Wife, 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

100
            $_convert = \PhpGedcom\Writer\Fam\Even\Wife::convert(/** @scrutinizer ignore-type */ $wife, $level);
Loading history...
101
            $output .= $_convert;
102
        }
103
104
        // $ref = array();
105
        // This is not in parser
106
107
        // $obje = array();
108
        $obje = $even->getObje();
0 ignored issues
show
Bug introduced by
The method getObje() does not exist on PhpGedcom\Record\Fam\Even. 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

108
        /** @scrutinizer ignore-call */ 
109
        $obje = $even->getObje();
Loading history...
109
        if (!empty($obje) && count($obje) > 0) {
110
            foreach ($obje as $item) {
111
                $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level);
112
                $output .= $_convert;
113
            }
114
        }
115
        // $sour = array();
116
        $sour = $even->getSour();
0 ignored issues
show
Bug introduced by
The method getSour() does not exist on PhpGedcom\Record\Fam\Even. 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

116
        /** @scrutinizer ignore-call */ 
117
        $sour = $even->getSour();
Loading history...
117
        if (!empty($sour) && count($sour) > 0) {
118
            foreach ($sour as $item) {
119
                $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level);
120
                $output .= $_convert;
121
            }
122
        }
123
        // $note = array();
124
        $note = $even->getNote();
0 ignored issues
show
Bug introduced by
The method getNote() does not exist on PhpGedcom\Record\Fam\Even. 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

124
        /** @scrutinizer ignore-call */ 
125
        $note = $even->getNote();
Loading history...
125
        if (!empty($note) && count($note) > 0) {
126
            foreach ($note as $item) {
127
                $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level);
128
                $output .= $_convert;
129
            }
130
        }
131
132
        return $output;
133
    }
134
}
135