| Conditions | 7 |
| Paths | 2 |
| Total Lines | 40 |
| Code Lines | 27 |
| 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 | $parser->forward(); |
||
| 25 | |||
| 26 | $chan = new \PhpGedcom\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 = \PhpGedcom\Parser\NoteRef::parse($parser); |
||
| 47 | if ($note) { |
||
| 48 | $chan->addNote($note); |
||
| 49 | } |
||
| 50 | break; |
||
| 51 | default: |
||
| 52 | $parser->logUnhandledRecord(get_class().' @ '.__LINE__); |
||
| 53 | } |
||
| 54 | |||
| 55 | $parser->forward(); |
||
| 56 | } |
||
| 57 | |||
| 58 | return $chan; |
||
| 59 | } |
||
| 61 |