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 Gedcom\Parser; |
||||||
16 | |||||||
17 | class Fam extends \Gedcom\Parser\Component |
||||||
18 | { |
||||||
19 | protected static $_eventTypes = [ |
||||||
20 | 'ANUL', |
||||||
21 | 'CENS', |
||||||
22 | 'DIV', |
||||||
23 | 'DIVF', |
||||||
24 | 'ENGA', |
||||||
25 | 'MARR', |
||||||
26 | 'MARB', |
||||||
27 | 'MARC', |
||||||
28 | 'MARL', |
||||||
29 | 'MARS', |
||||||
30 | ]; |
||||||
31 | |||||||
32 | public static function parse(\Gedcom\Parser $parser) |
||||||
33 | { |
||||||
34 | $record = $parser->getCurrentLineRecord(); |
||||||
35 | $depth = (int) $record[0]; |
||||||
36 | if (isset($record[1])) { |
||||||
37 | $identifier = $parser->normalizeIdentifier($record[1]); |
||||||
38 | } else { |
||||||
39 | $parser->skipToNextLevel($depth); |
||||||
40 | |||||||
41 | return null; |
||||||
42 | } |
||||||
43 | |||||||
44 | $fam = new \Gedcom\Record\Fam(); |
||||||
45 | $fam->setId($identifier); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
46 | |||||||
47 | $parser->getGedcom()->addFam($fam); |
||||||
48 | |||||||
49 | $parser->forward(); |
||||||
50 | |||||||
51 | while (!$parser->eof()) { |
||||||
52 | $record = $parser->getCurrentLineRecord(); |
||||||
53 | $currentDepth = (int) $record[0]; |
||||||
54 | $recordType = strtoupper(trim($record[1])); |
||||||
55 | |||||||
56 | if ($currentDepth <= $depth) { |
||||||
57 | $parser->back(); |
||||||
58 | break; |
||||||
59 | } |
||||||
60 | |||||||
61 | switch ($recordType) { |
||||||
62 | case 'RESN': |
||||||
63 | $fam->setResn(trim($record[2])); |
||||||
0 ignored issues
–
show
The method
setResn() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
64 | break; |
||||||
65 | case 'EVEN': |
||||||
66 | case 'ANUL': |
||||||
67 | case 'CENS': |
||||||
68 | case 'DIV': |
||||||
69 | case 'DIVF': |
||||||
70 | case 'ENGA': |
||||||
71 | case 'MARR': |
||||||
72 | case 'MARB': |
||||||
73 | case 'MARC': |
||||||
74 | case 'MARL': |
||||||
75 | case 'MARS': |
||||||
76 | $className = ucfirst(strtolower($recordType)); |
||||||
77 | $class = '\\Gedcom\\Parser\\Fam\\'.$className; |
||||||
78 | |||||||
79 | $even = $class::parse($parser); |
||||||
80 | $fam->addEven($even); |
||||||
81 | break; |
||||||
82 | case 'HUSB': |
||||||
83 | $fam->setHusb($parser->normalizeIdentifier($record[2])); |
||||||
0 ignored issues
–
show
The method
setHusb() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
84 | break; |
||||||
85 | case 'WIFE': |
||||||
86 | $fam->setWife($parser->normalizeIdentifier($record[2])); |
||||||
0 ignored issues
–
show
The method
setWife() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
87 | break; |
||||||
88 | case 'CHIL': |
||||||
89 | $fam->addChil($parser->normalizeIdentifier($record[2])); |
||||||
0 ignored issues
–
show
The method
addChil() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
90 | break; |
||||||
91 | case 'NCHI': |
||||||
92 | $fam->setNchi(trim($record[2])); |
||||||
0 ignored issues
–
show
The method
setNchi() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
93 | break; |
||||||
94 | case 'SUBM': |
||||||
95 | $fam->addSubm($parser->normalizeIdentifier($record[2])); |
||||||
0 ignored issues
–
show
The method
addSubm() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
96 | break; |
||||||
97 | case 'SLGS': |
||||||
98 | $slgs = \Gedcom\Parser\Fam\Slgs::parse($parser); |
||||||
99 | $fam->addSlgs($slgs); |
||||||
100 | break; |
||||||
101 | case 'REFN': |
||||||
102 | $ref = \Gedcom\Parser\Refn::parse($parser); |
||||||
103 | $fam->addRefn($ref); |
||||||
104 | break; |
||||||
105 | case 'RIN': |
||||||
106 | $fam->setRin(trim($record[2])); |
||||||
0 ignored issues
–
show
The method
setRin() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
107 | break; |
||||||
108 | case 'CHAN': |
||||||
109 | $chan = \Gedcom\Parser\Chan::parse($parser); |
||||||
110 | $fam->setChan($chan); |
||||||
0 ignored issues
–
show
The method
setChan() does not exist on Gedcom\Record\Fam . 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
![]() |
|||||||
111 | break; |
||||||
112 | case 'NOTE': |
||||||
113 | $note = \Gedcom\Parser\NoteRef::parse($parser); |
||||||
114 | if ($note) { |
||||||
115 | $fam->addNote($note); |
||||||
116 | } |
||||||
117 | break; |
||||||
118 | case 'SOUR': |
||||||
119 | $sour = \Gedcom\Parser\SourRef::parse($parser); |
||||||
120 | $fam->addSour($sour); |
||||||
121 | break; |
||||||
122 | case 'OBJE': |
||||||
123 | $obje = \Gedcom\Parser\ObjeRef::parse($parser); |
||||||
124 | $fam->addObje($obje); |
||||||
125 | break; |
||||||
126 | |||||||
127 | default: |
||||||
128 | $parser->logUnhandledRecord(self::class.' @ '.__LINE__); |
||||||
129 | } |
||||||
130 | |||||||
131 | $parser->forward(); |
||||||
132 | } |
||||||
133 | |||||||
134 | return $fam; |
||||||
135 | } |
||||||
136 | } |
||||||
137 |