NoteRef::convert()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 11
nc 4
nop 2
dl 0
loc 21
rs 9.6111
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;
16
17
class NoteRef
18
{
19
    /**
20
     * @param \PhpGedcom\Record\NoteRef $note
21
     * @param int                       $level
22
     *
23
     * @return string
24
     */
25
    public static function convert(\PhpGedcom\Record\NoteRef &$note, $level)
26
    {
27
        $output = '';
28
29
        // $_note
30
        $_note = $note->getNote();
0 ignored issues
show
Bug introduced by
The method getNote() does not exist on PhpGedcom\Record\NoteRef. 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

30
        /** @scrutinizer ignore-call */ 
31
        $_note = $note->getNote();
Loading history...
31
        if (!empty($_note)) {
32
            $output .= $level.' NOTE '.$_note."\n";
0 ignored issues
show
Bug introduced by
Are you sure $_note of type PhpGedcom\Record\NoteRef|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

32
            $output .= $level.' NOTE './** @scrutinizer ignore-type */ $_note."\n";
Loading history...
33
        }
34
35
        $level++;
36
        // $sour
37
        $sour = $note->getSour();
0 ignored issues
show
Bug introduced by
The method getSour() does not exist on PhpGedcom\Record\NoteRef. 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

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

38
        if ($sour && count(/** @scrutinizer ignore-type */ $sour) > 0) {
Loading history...
39
            foreach ($sour as $item) {
40
                $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level);
41
                $output .= $_convert;
42
            }
43
        }
44
45
        return $output;
46
    }
47
}
48