File::parse()   B
last analyzed

Complexity

Conditions 6
Paths 3

Size

Total Lines 36
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 36
c 0
b 0
f 0
rs 8.8977
cc 6
nc 3
nop 1
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 Gedcom\Parser\ObjeRef;
16
17
class File extends \Gedcom\Parser\Component
18
{
19
    public static function parse(\Gedcom\Parser $parser)
20
    {
21
        $file = new \Gedcom\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 Gedcom\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(\Parser\ObjeRef\File\Form::parse($parser));
0 ignored issues
show
Bug introduced by
The method setDate() does not exist on Gedcom\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(\Parser\ObjeRef\File\Form::parse($parser));
Loading history...
Bug introduced by
The type Parser\ObjeRef\File\Form was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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 Gedcom\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(self::class.' @ '.__LINE__);
49
            }
50
51
            $parser->forward();
52
        }
53
54
        return $file;
55
    }
56
}
57