Caln   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 37 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 PhpGedcom\Parser;
16
17
class Caln extends \PhpGedcom\Parser\Component
18
{
19
    public static function parse(\PhpGedcom\Parser $parser)
20
    {
21
        $record = $parser->getCurrentLineRecord();
22
        $depth = (int) $record[0];
23
        if (isset($record[2])) {
24
            $identifier = $parser->normalizeIdentifier($record[2]);
25
        } else {
26
            $parser->skipToNextLevel($depth);
27
28
            return null;
29
        }
30
31
        $caln = new \PhpGedcom\Record\Caln();
32
        $caln->setCaln($identifier);
33
34
        $parser->forward();
35
36
        while (!$parser->eof()) {
37
            $record = $parser->getCurrentLineRecord();
38
            $recordType = strtolower(trim($record[1]));
39
            $lineDepth = (int) $record[0];
40
41
            if ($lineDepth <= $depth) {
42
                $parser->back();
43
                break;
44
            }
45
46
            if ($caln->hasAttribute($recordType)) {
47
                $caln->{'set'.$recordType}(trim($record[2]));
48
            } else {
49
                $parser->logUnhandledRecord(get_class().' @ '.__LINE__);
50
            }
51
52
            $parser->forward();
53
        }
54
55
        return $caln;
56
    }
57
}
58