Form   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 28
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
B parse() 0 39 6
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\ObjeRef\File;
16
17
class Form extends \PhpGedcom\Parser\Component
18
{
19
    public static function parse(\PhpGedcom\Parser $parser)
20
    {
21
        $form = new \PhpGedcom\Record\ObjeRef\File\Form();
22
        $record = $parser->getCurrentLineRecord();
23
        $depth = (int) $record[0];
24
        if (isset($record[2])) {
25
            $form->setForm($record[2]);
0 ignored issues
show
Bug introduced by
The method setForm() does not exist on PhpGedcom\Record\ObjeRef\File\Form. 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
            $form->/** @scrutinizer ignore-call */ 
26
                   setForm($record[2]);
Loading history...
26
        } else {
27
            $parser->skipToNextLevel($depth);
28
29
            return null;
30
        }
31
        $parser->forward();
32
33
        while (!$parser->eof()) {
34
            $record = $parser->getCurrentLineRecord();
35
            $recordType = strtoupper(trim($record[1]));
36
            $currentDepth = (int) $record[0];
37
38
            if ($currentDepth <= $depth) {
39
                $parser->back();
40
                break;
41
            }
42
43
            switch ($recordType) {
44
                case 'MEDI':
45
                    $form->setMedi(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setMedi() does not exist on PhpGedcom\Record\ObjeRef\File\Form. 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
                    $form->/** @scrutinizer ignore-call */ 
46
                           setMedi(trim($record[2]));
Loading history...
46
                    break;
47
                case 'TYPE':
48
                    $form->setType(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setType() does not exist on PhpGedcom\Record\ObjeRef\File\Form. 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
                    $form->/** @scrutinizer ignore-call */ 
49
                           setType(trim($record[2]));
Loading history...
49
                    break;
50
                default:
51
                    $parser->logUnhandledRecord(get_class().' @ '.__LINE__);
52
            }
53
54
            $parser->forward();
55
        }
56
57
        return $form;
58
    }
59
}
60