Sour::convert()   B
last analyzed

Complexity

Conditions 6
Paths 17

Size

Total Lines 40
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 22
nc 17
nop 2
dl 0
loc 40
rs 8.9457
c 0
b 0
f 0
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\Head;
16
17
class Sour
18
{
19
    /**
20
     * @param \PhpGedcom\Record\Head\Sour $sour
21
     * @param string                      $format
22
     * @param int                         $level
23
     *
24
     * @return string
25
     */
26
    public static function convert(\PhpGedcom\Record\Head\Sour &$sour, $level)
27
    {
28
        $output = '';
29
        $_sour = $sour->getSour();
0 ignored issues
show
Bug introduced by
The method getSour() does not exist on PhpGedcom\Record\Head\Sour. 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
        $_sour = $sour->getSour();
Loading history...
30
        if ($_sour) {
31
            $output .= $level.' SOUR '.$_sour."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_sour of type PhpGedcom\Record\Head\Sour|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

31
            $output .= $level.' SOUR './** @scrutinizer ignore-type */ $_sour."\n";
Loading history...
32
        } else {
33
            return $output;
34
        }
35
36
        // level up
37
        $level++;
38
39
        // VERS
40
        $vers = $sour->getVersion();
41
        if ($vers) {
0 ignored issues
show
introduced by
$vers is of type PhpGedcom\Record\Head\Sour\Version, thus it always evaluated to true.
Loading history...
42
            $output .= $level.' VERS '.$vers."\n";
43
        }
44
45
        // NAME
46
        $name = $sour->getName();
47
        if ($name) {
0 ignored issues
show
introduced by
$name is of type PhpGedcom\Record\Head\Sour\Name, thus it always evaluated to true.
Loading history...
48
            $output .= $level.' NAME '.$name."\n";
49
        }
50
51
        // CORP
52
        $corp = $sour->getCorp();
53
        if ($corp) {
0 ignored issues
show
introduced by
$corp is of type PhpGedcom\Record\Head\Sour\Corp, thus it always evaluated to true.
Loading history...
54
            $_convert = \PhpGedcom\Writer\Head\Sour\Corp::convert($corp, $level);
55
            $output .= $_convert;
56
        }
57
58
        // DATA
59
        $data = $sour->getData();
60
        if ($data) {
0 ignored issues
show
introduced by
$data is of type PhpGedcom\Record\Head\Sour\Data, thus it always evaluated to true.
Loading history...
61
            $_convert = \PhpGedcom\Writer\Head\Sour\Data::convert($data, $level);
62
            $output .= $_convert;
63
        }
64
65
        return $output;
66
    }
67
}
68