Test Failed
Push — master ( 3f892b...ca4849 )
by Curtis
03:14 queued 02:42
created

Deat::parse()   B

Complexity

Conditions 7
Paths 2

Size

Total Lines 40
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 28
c 1
b 0
f 0
dl 0
loc 40
rs 8.5386
cc 7
nc 2
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;
16
17
class Deat extends \Gedcom\Parser\Component
18
{
19
    public static function parse(\Gedcom\Parser $parser)
20
    {
21
        $record = $parser->getCurrentLineRecord();
22
        $depth = (int) $record[0];
23
24
        $parser->forward();
25
26
        $deat = new \Gedcom\Record\Deat();
27
28
        while (!$parser->eof()) {
29
            $record = $parser->getCurrentLineRecord();
30
            $recordType = trim($record[1]);
31
            $currentDepth = (int) $record[0];
32
33
            if ($currentDepth <= $depth) {
34
                $parser->back();
35
                break;
36
            }
37
38
            switch ($recordType) {
39
                case 'DATE':
40
                    $deat->setDate(trim($record[2]));
41
                    break;
42
                case '_DATI':
43
                    $deat->setDati(trim($record[2]));
44
                    break;
45
                case 'PLAC':
46
                    $deat->setPlac(trim($record[2]));
47
                    break;
48
                case 'CAUS':
49
                    $deat->setCaus(trim($record[2]));
50
                    break;
51
                default:
52
                    $parser->logUnhandledRecord(self::class.' @ '.__LINE__);
53
            }
54
55
            $parser->forward();
56
        }
57
58
        return $deat;
59
    }
60
}
61