Test Failed
Push — master ( ca4849...698ad9 )
by Curtis
09:50 queued 07:00
created

Chr   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
eloc 23
c 1
b 1
f 0
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 34 5
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 Chr 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
        $chr = new \Gedcom\Record\Chr();
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
                    $chr->setDate(trim($record[2]));
41
                    break;
42
                case 'PLAC':
43
                    $chr->setPlac(trim($record[2]));
44
                    break;
45
                default:
46
                    $parser->logUnhandledRecord(self::class.' @ '.__LINE__);
47
            }
48
49
            $parser->forward();
50
        }
51
52
        return $chr;
53
    }
54
}
55