Conditions | 7 |
Paths | 3 |
Total Lines | 47 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public static function parse(\PhpGedcom\Parser $parser) |
||
20 | { |
||
21 | $record = $parser->getCurrentLineRecord(); |
||
22 | $depth = (int) $record[0]; |
||
23 | |||
24 | if (count($record) < 3) { |
||
|
|||
25 | $parser->logSkippedRecord('Missing family information; '.get_class(), ' @ '.__LINE__); |
||
26 | $parser->skipToNextLevel($depth); |
||
27 | |||
28 | return null; |
||
29 | } |
||
30 | |||
31 | $famc = $parser->normalizeIdentifier($record[2]); |
||
32 | |||
33 | $fam = new \PhpGedcom\Record\Indi\Famc(); |
||
34 | $fam->setFamc($famc); |
||
35 | |||
36 | $parser->forward(); |
||
37 | |||
38 | while (!$parser->eof()) { |
||
39 | $record = $parser->getCurrentLineRecord(); |
||
40 | $recordType = strtoupper(trim($record[1])); |
||
41 | $currentDepth = (int) $record[0]; |
||
42 | |||
43 | if ($currentDepth <= $depth) { |
||
44 | $parser->back(); |
||
45 | break; |
||
46 | } |
||
47 | |||
48 | switch ($recordType) { |
||
49 | case 'PEDI': |
||
50 | $fam->setPedi(trim($record[2])); |
||
51 | break; |
||
52 | case 'NOTE': |
||
53 | $note = \PhpGedcom\Parser\NoteRef::parse($parser); |
||
54 | if ($note) { |
||
55 | $fam->addNote($note); |
||
56 | } |
||
57 | break; |
||
58 | default: |
||
59 | $parser->logUnhandledRecord(get_class().' @ '.__LINE__); |
||
60 | } |
||
61 | |||
62 | $parser->forward(); |
||
63 | } |
||
64 | |||
65 | return $fam; |
||
66 | } |
||
68 |