Data   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B convert() 0 44 10
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\Sour;
16
17
class Data
18
{
19
    /**
20
     * @param \PhpGedcom\Record\Sour\Data $data
21
     * @param int                         $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\PhpGedcom\Record\Sour\Data &$data, $level = 0)
26
    {
27
        $output = '';
0 ignored issues
show
Unused Code introduced by
The assignment to $output is dead and can be removed.
Loading history...
28
29
        $output = $level." DATA\n";
30
        $level++;
31
32
        // $_date;
33
        $date = $data->getDate();
0 ignored issues
show
Bug introduced by
The method getDate() does not exist on PhpGedcom\Record\Sour\Data. 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

33
        /** @scrutinizer ignore-call */ 
34
        $date = $data->getDate();
Loading history...
34
        if (!empty($date)) {
35
            $output .= $level.' DATE '.$date."\n";
0 ignored issues
show
Bug introduced by
Are you sure $date of type PhpGedcom\Record\Sour\Data|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.' DATE './** @scrutinizer ignore-type */ $date."\n";
Loading history...
36
        }
37
38
        // $_agnc AGNC
39
        $_agnc = $data->getAgnc();
0 ignored issues
show
Bug introduced by
The method getAgnc() does not exist on PhpGedcom\Record\Sour\Data. 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

39
        /** @scrutinizer ignore-call */ 
40
        $_agnc = $data->getAgnc();
Loading history...
40
        if (!empty($_agnc)) {
41
            $output .= $level.' AGNC '.$_agnc."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_agnc of type PhpGedcom\Record\Sour\Data|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

41
            $output .= $level.' AGNC './** @scrutinizer ignore-type */ $_agnc."\n";
Loading history...
42
        }
43
44
        // $_text
45
        $_text = $data->getText();
0 ignored issues
show
Bug introduced by
The method getText() does not exist on PhpGedcom\Record\Sour\Data. 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

45
        /** @scrutinizer ignore-call */ 
46
        $_text = $data->getText();
Loading history...
46
        if (!empty($_text)) {
47
            $output .= $level.' TEXT '.$_text."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_text of type PhpGedcom\Record\Sour\Data|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

47
            $output .= $level.' TEXT './** @scrutinizer ignore-type */ $_text."\n";
Loading history...
48
        }
49
50
        // $_note
51
        $note = $data->getNote();
0 ignored issues
show
Bug introduced by
The method getNote() does not exist on PhpGedcom\Record\Sour\Data. 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

51
        /** @scrutinizer ignore-call */ 
52
        $note = $data->getNote();
Loading history...
52
        if ($note && count($note) > 0) {
0 ignored issues
show
Bug introduced by
It seems like $note can also be of type PhpGedcom\Record\Sour\Data; 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

52
        if ($note && count(/** @scrutinizer ignore-type */ $note) > 0) {
Loading history...
53
            foreach ($note as $item) {
54
                $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level);
55
                $output .= $_convert;
56
            }
57
        }
58
59
        // $_even
60
        $_even = $data->getEven();
0 ignored issues
show
Bug introduced by
The method getEven() does not exist on PhpGedcom\Record\Sour\Data. 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
        $_even = $data->getEven();
Loading history...
61
        if ($_even && count($_even) > 0) {
62
            foreach ($_even as $item) {
63
                $_convert = \PhpGedcom\Writer\Sour\Data\Even::convert($item, $level);
64
                $output .= $_convert;
65
            }
66
        }
67
68
        return $output;
69
    }
70
}
71