| Conditions | 8 |
| Paths | 3 |
| Total Lines | 48 |
| Code Lines | 35 |
| 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 | if (isset($record[2])) { |
||
| 24 | $source = new \PhpGedcom\Record\Head\Sour(); |
||
| 25 | $source->setSour(trim($record[2])); |
||
|
|
|||
| 26 | } else { |
||
| 27 | $parser->skipToNextLevel($depth); |
||
| 28 | |||
| 29 | return null; |
||
| 30 | } |
||
| 31 | |||
| 32 | $parser->forward(); |
||
| 33 | |||
| 34 | while (!$parser->eof()) { |
||
| 35 | $record = $parser->getCurrentLineRecord(); |
||
| 36 | $recordType = strtoupper(trim($record[1])); |
||
| 37 | $currentDepth = (int) $record[0]; |
||
| 38 | |||
| 39 | if ($currentDepth <= $depth) { |
||
| 40 | $parser->back(); |
||
| 41 | break; |
||
| 42 | } |
||
| 43 | |||
| 44 | switch ($recordType) { |
||
| 45 | case 'VERS': |
||
| 46 | $source->setVers(trim($record[2])); |
||
| 47 | break; |
||
| 48 | case 'NAME': |
||
| 49 | $source->setName(trim($record[2])); |
||
| 50 | break; |
||
| 51 | case 'CORP': |
||
| 52 | $corp = \PhpGedcom\Parser\Head\Sour\Corp::parse($parser); |
||
| 53 | $source->setCorp($corp); |
||
| 54 | break; |
||
| 55 | case 'DATA': |
||
| 56 | $data = \PhpGedcom\Parser\Head\Sour\Data::parse($parser); |
||
| 57 | $source->setData($data); |
||
| 58 | break; |
||
| 59 | default: |
||
| 60 | $parser->logUnhandledRecord(get_class().' @ '.__LINE__); |
||
| 61 | } |
||
| 62 | |||
| 63 | $parser->forward(); |
||
| 64 | } |
||
| 65 | |||
| 66 | return $source; |
||
| 67 | } |
||
| 69 |