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

Slgs::convert()   B

Complexity

Conditions 11
Paths 64

Size

Total Lines 50
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 26
nc 64
nop 2
dl 0
loc 50
rs 7.3166
c 0
b 0
f 0

How to fix   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 Slgs
21
{
22
    /**
23
     * @param \PhpGedcom\Record\Fam\Slgs $slgs
24
     * @param int $level
25
     * @return string
26
     */
27
    public static function convert(\PhpGedcom\Record\Fam\Slgs &$slgs, $level)
28
    {
29
        $output = "";
30
        $output.=$level." SLGS \n";
31
        
32
        // Level up
33
        $level++;
34
35
        // $STAT;
36
        $stat = $slgs->getStat();
0 ignored issues
show
Bug introduced by
The method getStat() does not exist on PhpGedcom\Record\Fam\Slgs. 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

36
        /** @scrutinizer ignore-call */ 
37
        $stat = $slgs->getStat();
Loading history...
37
        if(!empty($stat)){
38
            $output.=$level." STAT ".$stat."\n";
0 ignored issues
show
Bug introduced by
Are you sure $stat of type PhpGedcom\Record\Fam\Slgs|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

38
            $output.=$level." STAT "./** @scrutinizer ignore-type */ $stat."\n";
Loading history...
39
        }
40
41
        // $date;
42
        $date = $slgs->getDate();
0 ignored issues
show
Bug introduced by
The method getDate() does not exist on PhpGedcom\Record\Fam\Slgs. 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

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

44
            $output.=$level." DATE "./** @scrutinizer ignore-type */ $date."\n";
Loading history...
45
        }
46
        
47
        // PLAC
48
        $plac = $slgs->getPlac();
0 ignored issues
show
Bug introduced by
The method getPlac() does not exist on PhpGedcom\Record\Fam\Slgs. 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

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

50
            $output.=$level." PLAC "./** @scrutinizer ignore-type */ $plac."\n";
Loading history...
51
        }
52
53
        // $TEMP;
54
        $temp = $slgs->getTemp();
0 ignored issues
show
Bug introduced by
The method getTemp() does not exist on PhpGedcom\Record\Fam\Slgs. 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

54
        /** @scrutinizer ignore-call */ 
55
        $temp = $slgs->getTemp();
Loading history...
55
        if(!empty($temp)){
56
            $output.=$level." TEMP ".$temp."\n";
0 ignored issues
show
Bug introduced by
Are you sure $temp of type PhpGedcom\Record\Fam\Slgs|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

56
            $output.=$level." TEMP "./** @scrutinizer ignore-type */ $temp."\n";
Loading history...
57
        }
58
59
        // $sour = array();
60
        $sour = $slgs->getSour();
0 ignored issues
show
Bug introduced by
The method getSour() does not exist on PhpGedcom\Record\Fam\Slgs. 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
        $sour = $slgs->getSour();
Loading history...
61
        if(!empty($sour) && count($sour) > 0){
0 ignored issues
show
Bug introduced by
It seems like $sour can also be of type PhpGedcom\Record\Fam\Slgs; 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

61
        if(!empty($sour) && count(/** @scrutinizer ignore-type */ $sour) > 0){
Loading history...
62
            foreach($sour as $item){
63
                $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level);
64
                $output.=$_convert;
65
            }
66
        }
67
        // $note = array();
68
        $note = $slgs->getNote();
0 ignored issues
show
Bug introduced by
The method getNote() does not exist on PhpGedcom\Record\Fam\Slgs. 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

68
        /** @scrutinizer ignore-call */ 
69
        $note = $slgs->getNote();
Loading history...
69
        if(!empty($note) && count($note) > 0){
70
            foreach($note as $item){
71
                $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level);
72
                $output.=$_convert;
73
            }
74
        }
75
       
76
        return $output;
77
    }
78
}
79