genealogiawebsite /
php-gedcom
| 1 | <?php |
||||||
| 2 | /** |
||||||
| 3 | * php-gedcom. |
||||||
| 4 | * |
||||||
| 5 | * php-gedcom is a library for parsing, manipulating, importing and exporting |
||||||
| 6 | * GEDCOM 5.5 files in PHP 5.3+. |
||||||
| 7 | * |
||||||
| 8 | * @author Kristopher Wilson <[email protected]> |
||||||
| 9 | * @copyright Copyright (c) 2010-2013, Kristopher Wilson |
||||||
| 10 | * @license MIT |
||||||
| 11 | * |
||||||
| 12 | * @link http://github.com/mrkrstphr/php-gedcom |
||||||
| 13 | */ |
||||||
| 14 | |||||||
| 15 | namespace PhpGedcom\Parser; |
||||||
| 16 | |||||||
| 17 | class Obje extends \PhpGedcom\Parser\Component |
||||||
| 18 | { |
||||||
| 19 | public static function parse(\PhpGedcom\Parser $parser) |
||||||
| 20 | { |
||||||
| 21 | $record = $parser->getCurrentLineRecord(); |
||||||
| 22 | $depth = (int) $record[0]; |
||||||
| 23 | if (isset($record[1])) { |
||||||
| 24 | $identifier = $parser->normalizeIdentifier($record[1]); |
||||||
| 25 | } else { |
||||||
| 26 | $parser->skipToNextLevel($depth); |
||||||
| 27 | |||||||
| 28 | return null; |
||||||
| 29 | } |
||||||
| 30 | |||||||
| 31 | $obje = new \PhpGedcom\Record\Obje(); |
||||||
| 32 | $obje->setId($identifier); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 33 | |||||||
| 34 | $parser->getGedcom()->addObje($obje); |
||||||
| 35 | |||||||
| 36 | $parser->forward(); |
||||||
| 37 | |||||||
| 38 | while (!$parser->eof()) { |
||||||
| 39 | $record = $parser->getCurrentLineRecord(); |
||||||
| 40 | $currentDepth = (int) $record[0]; |
||||||
| 41 | $recordType = strtoupper(trim($record[1])); |
||||||
| 42 | |||||||
| 43 | if ($currentDepth <= $depth) { |
||||||
| 44 | $parser->back(); |
||||||
| 45 | break; |
||||||
| 46 | } |
||||||
| 47 | |||||||
| 48 | switch ($recordType) { |
||||||
| 49 | case 'FILE': |
||||||
| 50 | $obje->setFile(trim($record[2])); |
||||||
|
0 ignored issues
–
show
The method
setFile() does not exist on PhpGedcom\Record\Obje. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 51 | break; |
||||||
| 52 | case 'REFN': |
||||||
| 53 | $refn = \PhpGedcom\Parser\Refn::parse($parser); |
||||||
| 54 | $obje->addRefn($refn); |
||||||
| 55 | break; |
||||||
| 56 | case 'RIN': |
||||||
| 57 | $obje->setRin(trim($record[2])); |
||||||
|
0 ignored issues
–
show
The method
setRin() does not exist on PhpGedcom\Record\Obje. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 58 | break; |
||||||
| 59 | |||||||
| 60 | case 'NOTE': |
||||||
| 61 | $note = \PhpGedcom\Parser\NoteRef::parse($parser); |
||||||
| 62 | if ($note) { |
||||||
| 63 | $obje->addNote($note); |
||||||
| 64 | } |
||||||
| 65 | break; |
||||||
| 66 | case 'SOUR': |
||||||
| 67 | $chan = \PhpGedcom\Parser\Chan::parse($parser); |
||||||
| 68 | $obje->setChan($chan); |
||||||
|
0 ignored issues
–
show
The method
setChan() does not exist on PhpGedcom\Record\Obje. Since you implemented __call, consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 69 | break; |
||||||
| 70 | |||||||
| 71 | case 'CHAN': |
||||||
| 72 | $chan = \PhpGedcom\Parser\Chan::parse($parser); |
||||||
| 73 | $obje->setChan($chan); |
||||||
| 74 | break; |
||||||
| 75 | |||||||
| 76 | default: |
||||||
| 77 | $parser->logUnhandledRecord(get_class().' @ '.__LINE__); |
||||||
| 78 | } |
||||||
| 79 | |||||||
| 80 | $parser->forward(); |
||||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | return $obje; |
||||||
| 84 | } |
||||||
| 85 | } |
||||||
| 86 |