Conditions | 7 |
Paths | 2 |
Total Lines | 43 |
Code Lines | 29 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public static function parse(\Gedcom\Parser $parser) |
||
20 | { |
||
21 | $record = $parser->getCurrentLineRecord(); |
||
22 | $depth = (int) $record[0]; |
||
23 | |||
24 | $parser->forward(); |
||
25 | |||
26 | $chan = new \Gedcom\Record\Chan(); |
||
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 | $chan->setDate(trim($record[2])); |
||
41 | break; |
||
42 | case 'TIME': |
||
43 | $chan->setTime(trim($record[2])); |
||
44 | break; |
||
45 | case 'NOTE': |
||
46 | $note = \Gedcom\Parser\NoteRef::parse($parser); |
||
47 | if ($note) { |
||
48 | $chan->addNote($note); |
||
49 | } |
||
50 | break; |
||
51 | default: |
||
52 | $parser->logUnhandledRecord(self::class.' @ '.__LINE__); |
||
53 | } |
||
54 | |||
55 | $parser->forward(); |
||
56 | } |
||
57 | |||
58 | $date = $chan->getYear().'-'.$chan->getMonth().'-'.$chan->getDay(); |
||
59 | $chan->setDatetime($date); |
||
60 | |||
61 | return $chan; |
||
62 | } |
||
64 |