Passed
Branch master (6a7148)
by Curtis
01:48
created

Husb::parse()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 31
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 19
nc 2
nop 1
dl 0
loc 31
rs 9.6333
c 0
b 0
f 0
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
 * @package         php-gedcom 
11
 * @license         MIT
12
 * @link            http://github.com/mrkrstphr/php-gedcom
13
 */
14
15
namespace PhpGedcom\Parser\Fam\Even;
16
17
/**
18
 *
19
 *
20
 */
21
class Husb extends \PhpGedcom\Parser\Component
22
{
23
    
24
    /**
25
     *
26
     *
27
     */
28
    public static function parse(\PhpGedcom\Parser $parser)
29
    {
30
        $record = $parser->getCurrentLineRecord();
31
        $depth = (int)$record[0];
32
        
33
        $husband = new \PhpGedcom\Record\Fam\Even\Husb();
34
        
35
        $parser->forward();
36
        
37
        while (!$parser->eof()) {
38
            $record = $parser->getCurrentLineRecord();
39
            $recordType = strtoupper(trim($record[1]));
40
            $currentDepth = (int)$record[0];
41
            
42
            if ($currentDepth <= $depth) {
43
                $parser->back();
44
                break;
45
            }
46
            
47
            switch ($recordType) {
48
                case 'AGE':
49
                    $husband->setAge(trim($record[2]));
0 ignored issues
show
Bug introduced by
The method setAge() does not exist on PhpGedcom\Record\Fam\Even\Husb. 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

49
                    $husband->/** @scrutinizer ignore-call */ 
50
                              setAge(trim($record[2]));
Loading history...
50
                    break;
51
                default:
52
                    $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__);
53
            }
54
            
55
            $parser->forward();
56
        }
57
        
58
        return $husband;
59
    }
60
}
61