| Conditions | 7 | 
| Paths | 4 | 
| Total Lines | 38 | 
| Code Lines | 24 | 
| 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 | $line = isset($record[2]) ? trim($record[2]) : ''; | ||
| 24 | |||
| 25 | $addr = new \PhpGedcom\Record\Addr(); | ||
| 26 | $addr->setAddr($line); | ||
| 27 | $parser->forward(); | ||
| 28 | |||
| 29 |         while (!$parser->eof()) { | ||
| 30 | $record = $parser->getCurrentLineRecord(); | ||
| 31 | $recordType = strtolower(trim($record[1])); | ||
| 32 | $currentDepth = (int) $record[0]; | ||
| 33 | |||
| 34 |             if ($currentDepth <= $depth) { | ||
| 35 | $parser->back(); | ||
| 36 | break; | ||
| 37 | } | ||
| 38 | |||
| 39 |             if ($addr->hasAttribute($recordType)) { | ||
| 40 |                 $addr->{'set'.$recordType}(trim($record[2])); | ||
| 41 |             } else { | ||
| 42 |                 if ($recordType == 'cont') { | ||
| 43 | // FIXME: Can have CONT on multiple attributes | ||
| 44 | $addr->setAddr($addr->getAddr()."\n"); | ||
| 45 |                     if (isset($record[2])) { | ||
| 46 | $addr->setAddr($addr->getAddr().trim($record[2])); | ||
| 47 | } | ||
| 48 |                 } else { | ||
| 49 | $parser->logUnhandledRecord(get_class().' @ '.__LINE__); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | $parser->forward(); | ||
| 54 | } | ||
| 55 | |||
| 56 | return $addr; | ||
| 57 | } | ||
| 59 |