Passed
Branch master (6a7148)
by Curtis
01:48
created

Even::convert()   F

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
 * @package         php-gedcom 
11
 * @license         MIT
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace PhpGedcom\Writer\Fam;
16
17
/**
18
 *
19
 */
20
class Even
21
{
22
    /**
23
     * @param \PhpGedcom\Record\Fam\Even $even
24
     * @param int $level
25
     * @return string
26
     */
27
    public static function convert(\PhpGedcom\Record\Fam\Even &$even, $level)
28
    {
29
        $output = "";
30
31
        // $type;
32
        $type = $even->getType();
33
        if(!empty($type)){
34
            $output.=$level." ".$type."\n";
35
        }else{
36
            return $output;
37
        }
38
        $level++;
39
40
        // $type;
41
        $type = $even->getType();
42
        if(!empty($type)){
43
            $output.=$level." TYPE ".$type."\n";
44
        }
45
46
        // $date;
47
        $date = $even->getDate();
48
        if(!empty($date)){
49
            $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

49
            $output.=$level." DATE "./** @scrutinizer ignore-type */ $date."\n";
Loading history...
50
        }
51
        
52
        // Plac
53
        $plac = $even->getPlac();
54
        if(!empty($plac)){
55
            $_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

55
            $_convert = \PhpGedcom\Writer\Indi\Even\Plac::convert(/** @scrutinizer ignore-type */ $plac, $level);
Loading history...
56
            $output.=$_convert;
57
        }
58
59
        // $caus;
60
        $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

60
        /** @scrutinizer ignore-call */ 
61
        $caus = $even->getCaus();
Loading history...
61
        if(!empty($caus)){
62
            $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

62
            $output.=$level." CAUS "./** @scrutinizer ignore-type */ $caus."\n";
Loading history...
63
        }
64
65
        // $age;
66
        $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

66
        /** @scrutinizer ignore-call */ 
67
        $age = $even->getAge();
Loading history...
67
        if(!empty($age)){
68
            $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

68
            $output.=$level." AGE "./** @scrutinizer ignore-type */ $age."\n";
Loading history...
69
        }
70
71
        // $addr
72
        $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

72
        /** @scrutinizer ignore-call */ 
73
        $addr = $even->getAddr();
Loading history...
73
        if(!empty($addr)){
74
            $_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

74
            $_convert = \PhpGedcom\Writer\Addr::convert(/** @scrutinizer ignore-type */ $addr, $level);
Loading history...
75
            $output.=$_convert;
76
        }
77
78
        // $phon = array()
79
        $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

79
        /** @scrutinizer ignore-call */ 
80
        $phon = $even->getPhon();
Loading history...
80
        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

80
        if(!empty($phon) && count(/** @scrutinizer ignore-type */ $phon) > 0){
Loading history...
81
            foreach($phon as $item){
82
                $_convert = \PhpGedcom\Writer\Phon::convert($item, $level);
83
                $output.=$_convert;
84
            }
85
        }
86
        // $agnc
87
        $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

87
        /** @scrutinizer ignore-call */ 
88
        $agnc = $even->getAgnc();
Loading history...
88
        if(!empty($agnc)){
89
            $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

89
            $output.=$level." AGNC "./** @scrutinizer ignore-type */ $agnc."\n";
Loading history...
90
        }
91
92
        // HUSB
93
        $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

93
        /** @scrutinizer ignore-call */ 
94
        $husb = $even->getHusb();
Loading history...
94
        if(!empty($husb)){
95
            $_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

95
            $_convert = \PhpGedcom\Writer\Fam\Even\Husb::convert(/** @scrutinizer ignore-type */ $husb, $level);
Loading history...
96
            $output.=$_convert;
97
        }
98
99
        // WIFE
100
        $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

100
        /** @scrutinizer ignore-call */ 
101
        $wife = $even->getWife();
Loading history...
101
        if(!empty($wife)){
102
            $_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

102
            $_convert = \PhpGedcom\Writer\Fam\Even\Wife::convert(/** @scrutinizer ignore-type */ $wife, $level);
Loading history...
103
            $output.=$_convert;
104
        }
105
106
        // $ref = array();
107
        // This is not in parser
108
109
        // $obje = array();
110
        $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

110
        /** @scrutinizer ignore-call */ 
111
        $obje = $even->getObje();
Loading history...
111
        if(!empty($obje) && count($obje) > 0){
112
            foreach($obje as $item){
113
                $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level);
114
                $output.=$_convert;
115
            }
116
        }
117
        // $sour = array();
118
        $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

118
        /** @scrutinizer ignore-call */ 
119
        $sour = $even->getSour();
Loading history...
119
        if(!empty($sour) && count($sour) > 0){
120
            foreach($sour as $item){
121
                $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level);
122
                $output.=$_convert;
123
            }
124
        }
125
        // $note = array();
126
        $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

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