| Conditions | 6 |
| Paths | 3 |
| Total Lines | 40 |
| Code Lines | 27 |
| 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 | if (isset($record[2])) { |
||
| 24 | $corp = new \Gedcom\Record\Head\Sour\Corp(); |
||
| 25 | $corp->setCorp(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 'ADDR': |
||
| 46 | $corp->setAddr(\Gedcom\Parser\Addr::parse($parser)); |
||
| 47 | break; |
||
| 48 | case 'PHON': |
||
| 49 | $corp->addPhon(trim($record[2])); |
||
| 50 | break; |
||
| 51 | default: |
||
| 52 | $parser->logUnhandledRecord(self::class.' @ '.__LINE__); |
||
| 53 | } |
||
| 54 | |||
| 55 | $parser->forward(); |
||
| 56 | } |
||
| 57 | |||
| 58 | return $corp; |
||
| 59 | } |
||
| 61 |