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

Fam::convert()   F

Complexity

Conditions 38
Paths 12289

Size

Total Lines 127
Code Lines 70

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 38
eloc 70
nc 12289
nop 2
dl 0
loc 127
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;
16
17
/**
18
 *
19
 */
20
class Fam
21
{
22
    /**
23
     * @param \PhpGedcom\Record\Fam $sour
24
     * @param int $level
25
     * @return string
26
     */
27
    public static function convert(\PhpGedcom\Record\Fam &$fam, $level=0)
28
    {
29
        
30
        $output = "";
31
        $id = $fam->getId();
0 ignored issues
show
Bug introduced by
The method getId() does not exist on PhpGedcom\Record\Fam. 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

31
        /** @scrutinizer ignore-call */ 
32
        $id = $fam->getId();
Loading history...
32
        if(empty($id)){
33
            return $output;
34
        }else{
35
            $output.=$level." @".$id."@ FAM "."\n";
0 ignored issues
show
Bug introduced by
Are you sure $id of type PhpGedcom\Record\Fam|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

35
            $output.=$level." @"./** @scrutinizer ignore-type */ $id."@ FAM "."\n";
Loading history...
36
        }
37
        // level up
38
        $level++;
39
40
        // HUSB
41
        $husb = $fam->getHusb();
0 ignored issues
show
Bug introduced by
The method getHusb() does not exist on PhpGedcom\Record\Fam. 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

41
        /** @scrutinizer ignore-call */ 
42
        $husb = $fam->getHusb();
Loading history...
42
        if(!empty($husb)){
43
            $output.=$level." HUSB @".$husb."@\n";
0 ignored issues
show
Bug introduced by
Are you sure $husb of type PhpGedcom\Record\Fam|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

43
            $output.=$level." HUSB @"./** @scrutinizer ignore-type */ $husb."@\n";
Loading history...
44
        }
45
        
46
        // WIFE
47
        $wife = $fam->getWife();
0 ignored issues
show
Bug introduced by
The method getWife() does not exist on PhpGedcom\Record\Fam. 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

47
        /** @scrutinizer ignore-call */ 
48
        $wife = $fam->getWife();
Loading history...
48
        if(!empty($wife)){
49
            $output.=$level." WIFE @".$wife."@\n";
0 ignored issues
show
Bug introduced by
Are you sure $wife of type PhpGedcom\Record\Fam|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

49
            $output.=$level." WIFE @"./** @scrutinizer ignore-type */ $wife."@\n";
Loading history...
50
        }
51
52
        // CHIL
53
        $chil = $fam->getChil();
0 ignored issues
show
Bug introduced by
The method getChil() does not exist on PhpGedcom\Record\Fam. 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

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

54
        if(!empty($chil) && count(/** @scrutinizer ignore-type */ $chil) > 0){
Loading history...
55
            foreach($chil as $item){
56
                if($item){
57
                    $_convert = $level." CHIL @".$item."@\n";
58
                    $output.=$_convert;
59
                }
60
            }
61
        }
62
        // NCHI
63
        $nchi = $fam->getNchi();
0 ignored issues
show
Bug introduced by
The method getNchi() does not exist on PhpGedcom\Record\Fam. 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

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

65
            $output.=$level." NCHI "./** @scrutinizer ignore-type */ $nchi."\n";
Loading history...
66
        }
67
68
        // SUBM array
69
        $subm = $fam->getSubm();
0 ignored issues
show
Bug introduced by
The method getSubm() does not exist on PhpGedcom\Record\Fam. 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

69
        /** @scrutinizer ignore-call */ 
70
        $subm = $fam->getSubm();
Loading history...
70
        
71
        if(!empty($subm) && count($subm) > 0){
72
            foreach($subm as $item){
73
                if($item){
74
                    $output.=$level." SUBM ".$item."\n";
75
                }
76
            }
77
        }
78
79
        // RIN
80
        $rin = $fam->getRin();
0 ignored issues
show
Bug introduced by
The method getRin() does not exist on PhpGedcom\Record\Fam. 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

80
        /** @scrutinizer ignore-call */ 
81
        $rin = $fam->getRin();
Loading history...
81
        if(!empty($rin)){
82
            $output.=$level." RIN ".$rin."\n";
0 ignored issues
show
Bug introduced by
Are you sure $rin of type PhpGedcom\Record\Fam|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

82
            $output.=$level." RIN "./** @scrutinizer ignore-type */ $rin."\n";
Loading history...
83
        }
84
        // CHAN
85
        $chan = $fam->getChan();
0 ignored issues
show
Bug introduced by
The method getChan() does not exist on PhpGedcom\Record\Fam. 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
        $chan = $fam->getChan();
Loading history...
86
        if(!empty($chan)){
87
            $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level);
0 ignored issues
show
Bug introduced by
It seems like $chan can also be of type PhpGedcom\Record\Fam; however, parameter $chan of PhpGedcom\Writer\Chan::convert() does only seem to accept PhpGedcom\Record\Chan, 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

87
            $_convert = \PhpGedcom\Writer\Chan::convert(/** @scrutinizer ignore-type */ $chan, $level);
Loading history...
88
            $output.=$_convert;
89
        }
90
        // SLGS
91
        $slgs = $fam->getSlgs();
0 ignored issues
show
Bug introduced by
The method getSlgs() does not exist on PhpGedcom\Record\Fam. 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
        $slgs = $fam->getSlgs();
Loading history...
92
        if(!empty($slgs) && count($slgs) > 0){
93
            if($slgs){
94
                $_convert = \PhpGedcom\Writer\Fam\Slgs::convert($item, $level);
95
                $output.=$_convert;
96
            }
97
        }
98
99
        // REFN array
100
        $refn = $fam->getRefn();
0 ignored issues
show
Bug introduced by
The method getRefn() does not exist on PhpGedcom\Record\Fam. 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
        $refn = $fam->getRefn();
Loading history...
101
        if(!empty($refn) && count($refn) > 0){
102
            foreach($refn as $item){
103
                if($item){
104
                    $_convert = \PhpGedcom\Writer\Refn::convert($item, $level);
105
                    $output.=$_convert;
106
                }
107
            }
108
        }
109
110
        // NOTE array
111
        $note = $fam->getNote();
0 ignored issues
show
Bug introduced by
The method getNote() does not exist on PhpGedcom\Record\Fam. 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

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

122
        /** @scrutinizer ignore-call */ 
123
        $sour = $fam->getSour();
Loading history...
123
        if(!empty($sour) && count($sour) > 0){
124
            foreach($sour as $item){
125
                if($item){
126
                    $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level);
127
                    $output.=$_convert;
128
                }
129
            }
130
        }
131
132
        // OBJE
133
        $obje = $fam->getObje();
0 ignored issues
show
Bug introduced by
The method getObje() does not exist on PhpGedcom\Record\Fam. 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

133
        /** @scrutinizer ignore-call */ 
134
        $obje = $fam->getObje();
Loading history...
134
        if(!empty($obje) && count($obje) > 0){
135
            foreach($obje as $item){
136
                if($item){
137
                    $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level);
138
                    $output.=$_convert;
139
                }
140
            }
141
        }
142
143
        // EVEN
144
        $even = $fam->getAllEven();
145
        if(!empty($even) && count($even) > 0){
146
            foreach($even as $item){
147
                if($item){
148
                    $_convert = \PhpGedcom\Writer\Fam\Even::convert($item, $level);
149
                    $output.=$_convert;
150
                }
151
            }
152
        }
153
        return $output;
154
    }
155
}
156