File   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 26
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 6

1 Method

Rating   Name   Duplication   Size   Complexity  
B parse() 0 36 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;
16
17
class File extends \PhpGedcom\Parser\Component
18
{
19
    public static function parse(\PhpGedcom\Parser $parser)
20
    {
21
        $file = new \PhpGedcom\Record\ObjeRef\File();
22
        $record = $parser->getCurrentLineRecord();
23
        $depth = (int) $record[0];
24
        if (isset($record[2])) {
25
            $file->setFile($record[2]);
0 ignored issues
show
Bug introduced by
The method setFile() does not exist on PhpGedcom\Record\ObjeRef\File. 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
            $file->/** @scrutinizer ignore-call */ 
26
                   setFile($record[2]);
Loading history...
26
        } else {
27
            return null;
28
        }
29
        $parser->forward();
30
31
        while (!$parser->eof()) {
32
            $record = $parser->getCurrentLineRecord();
33
            $recordType = strtoupper(trim($record[1]));
34
            $currentDepth = (int) $record[0];
35
36
            if ($currentDepth <= $depth) {
37
                $parser->back();
38
                break;
39
            }
40
41
            switch ($recordType) {
42
                case 'FORM':
43
                    $file->setDate(\PhpGedcom\Parser\ObjeRef\File\Form::parse($parser));
0 ignored issues
show
Bug introduced by
The method setDate() does not exist on PhpGedcom\Record\ObjeRef\File. 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

43
                    $file->/** @scrutinizer ignore-call */ 
44
                           setDate(\PhpGedcom\Parser\ObjeRef\File\Form::parse($parser));
Loading history...
44
                    break;
45
                case 'TITL':
46
                    $file->setTitl(trim($record[2]));
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment if this fall-through is intended.
Loading history...
Bug introduced by
The method setTitl() does not exist on PhpGedcom\Record\ObjeRef\File. 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
                    $file->/** @scrutinizer ignore-call */ 
47
                           setTitl(trim($record[2]));
Loading history...
47
                default:
48
                    $parser->logUnhandledRecord(get_class().' @ '.__LINE__);
49
            }
50
51
            $parser->forward();
52
        }
53
54
        return $file;
55
    }
56
}
57