Plac   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
B parse() 0 45 8
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 PhpGedcom\Parser\Indi\Even;
16
17
class Plac extends \PhpGedcom\Parser\Component
18
{
19
    public static function parse(\PhpGedcom\Parser $parser)
20
    {
21
        $record = $parser->getCurrentLineRecord();
22
        $depth = (int) $record[0];
23
24
        $plac = new \PhpGedcom\Record\Indi\Even\Plac();
25
26
        if (isset($record[2])) {
27
            $plac->setPlac(trim($record[2]));
28
        }
29
30
        $parser->forward();
31
32
        while (!$parser->eof()) {
33
            $record = $parser->getCurrentLineRecord();
34
            $recordType = strtoupper(trim($record[1]));
35
            $currentDepth = (int) $record[0];
36
37
            if ($currentDepth <= $depth) {
38
                $parser->back();
39
                break;
40
            }
41
42
            switch ($recordType) {
43
                case 'FORM':
44
                    $plac->setForm(trim($record[2]));
45
                    break;
46
                case 'NOTE':
47
                    $note = \PhpGedcom\Parser\NoteRef::parse($parser);
48
                    if ($note) {
49
                        $plac->addNote($note);
50
                    }
51
                    break;
52
                case 'SOUR':
53
                    $sour = \PhpGedcom\Parser\SourRef::parse($parser);
54
                    $plac->addSour($sour);
55
                    break;
56
                default:
57
                    $parser->logUnhandledRecord(get_class().' @ '.__LINE__);
58
            }
59
60
            $parser->forward();
61
        }
62
63
        return $plac;
64
    }
65
}
66