SourRef   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 48
dl 0
loc 64
rs 10
c 0
b 0
f 0
wmc 13

1 Method

Rating   Name   Duplication   Size   Complexity  
C parse() 0 62 13
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          Kristopher Wilson <[email protected]>
9
 * @copyright       Copyright (c) 2010-2013, Kristopher Wilson
10
 * @license         MIT
11
 *
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace PhpGedcom\Parser;
16
17
class SourRef extends \PhpGedcom\Parser\Component
18
{
19
    public static function parse(\PhpGedcom\Parser $parser)
20
    {
21
        $record = $parser->getCurrentLineRecord();
22
        $depth = (int) $record[0];
23
        if (isset($record[2])) {
24
            $sour = new \PhpGedcom\Record\SourRef();
25
            $sour->setSour($parser->normalizeIdentifier($record[2]));
0 ignored issues
show
Bug introduced by
The method setSour() does not exist on PhpGedcom\Record\SourRef. 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

25
            $sour->/** @scrutinizer ignore-call */ 
26
                   setSour($parser->normalizeIdentifier($record[2]));
Loading history...
26
        } else {
27
            $parser->skipToNextLevel($depth);
28
29
            return null;
30
        }
31
32
        $parser->forward();
33
34
        while (!$parser->eof()) {
35
            $record = $parser->getCurrentLineRecord();
36
            $recordType = strtoupper(trim($record[1]));
37
            $currentDepth = (int) $record[0];
38
39
            if ($currentDepth <= $depth) {
40
                $parser->back();
41
                break;
42
            }
43
44
            switch ($recordType) {
45
                case 'PAGE':
46
                    $sour->setPage(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setPage() does not exist on PhpGedcom\Record\SourRef. 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

46
                    $sour->/** @scrutinizer ignore-call */ 
47
                           setPage(trim($record[2]));
Loading history...
47
                    break;
48
                case 'EVEN':
49
                    $even = \PhpGedcom\Parser\SourRef\Even::parse($parser);
50
                    $sour->setEven($even);
0 ignored issues
show
Bug introduced by
The method setEven() does not exist on PhpGedcom\Record\SourRef. 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

50
                    $sour->/** @scrutinizer ignore-call */ 
51
                           setEven($even);
Loading history...
51
                    break;
52
                case 'DATA':
53
                    $sour->setData(\PhpGedcom\Parser\SourRef\Data::parse($parser));
0 ignored issues
show
Bug introduced by
The method setData() does not exist on PhpGedcom\Record\SourRef. 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
                    $sour->/** @scrutinizer ignore-call */ 
54
                           setData(\PhpGedcom\Parser\SourRef\Data::parse($parser));
Loading history...
54
                    break;
55
                case 'TEXT':
56
                    $sour->setText($parser->parseMultiLineRecord());
0 ignored issues
show
Bug introduced by
The method setText() does not exist on PhpGedcom\Record\SourRef. 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

56
                    $sour->/** @scrutinizer ignore-call */ 
57
                           setText($parser->parseMultiLineRecord());
Loading history...
57
                    break;
58
                case 'OBJE':
59
                    $obje = \PhpGedcom\Parser\ObjeRef::parse($parser);
60
                    if ($obje) {
61
                        $sour->addNote($obje);
0 ignored issues
show
Bug introduced by
The method addNote() does not exist on PhpGedcom\Record\SourRef. 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

61
                        $sour->/** @scrutinizer ignore-call */ 
62
                               addNote($obje);
Loading history...
62
                    }
63
                    break;
64
                case 'NOTE':
65
                    $note = \PhpGedcom\Parser\NoteRef::parse($parser);
66
                    if ($note) {
67
                        $sour->addNote($note);
68
                    }
69
                    break;
70
                case 'QUAY':
71
                    $sour->setQuay(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setQuay() does not exist on PhpGedcom\Record\SourRef. 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

71
                    $sour->/** @scrutinizer ignore-call */ 
72
                           setQuay(trim($record[2]));
Loading history...
72
                    break;
73
                default:
74
                    $parser->logUnhandledRecord(get_class().' @ '.__LINE__);
75
            }
76
77
            $parser->forward();
78
        }
79
80
        return $sour;
81
    }
82
}
83