Corp::parse()   B
last analyzed

Complexity

Conditions 6
Paths 3

Size

Total Lines 40
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 40
c 0
b 0
f 0
rs 8.8657
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\Head\Sour;
16
17
class Corp extends \Gedcom\Parser\Component
18
{
19
    public static function parse(\Gedcom\Parser $parser)
20
    {
21
        $record = $parser->getCurrentLineRecord();
22
        $depth = (int) $record[0];
23
        if (isset($record[2])) {
24
            $corp = new \Gedcom\Record\Head\Sour\Corp();
25
            $corp->setCorp(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setCorp() does not exist on Gedcom\Record\Head\Sour\Corp. 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
            $corp->/** @scrutinizer ignore-call */ 
26
                   setCorp(trim($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 'ADDR':
46
                    $corp->setAddr(\Gedcom\Parser\Addr::parse($parser));
0 ignored issues
show
Bug introduced by
The method setAddr() does not exist on Gedcom\Record\Head\Sour\Corp. 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
                    $corp->/** @scrutinizer ignore-call */ 
47
                           setAddr(\Gedcom\Parser\Addr::parse($parser));
Loading history...
47
                    break;
48
                case 'PHON':
49
                    $corp->addPhon(trim($record[2]));
50
                    break;
51
                default:
52
                    $parser->logUnhandledRecord(self::class.' @ '.__LINE__);
53
            }
54
55
            $parser->forward();
56
        }
57
58
        return $corp;
59
    }
60
}
61