modularsoftware /
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 Xiang Ming <[email protected]> |
||||||
| 9 | * @copyright Copyright (c) 2010-2013, Xiang Ming |
||||||
| 10 | * @license MIT |
||||||
| 11 | * |
||||||
| 12 | * @link http://github.com/mrkrstphr/php-gedcom |
||||||
| 13 | */ |
||||||
| 14 | |||||||
| 15 | namespace PhpGedcom\Writer; |
||||||
| 16 | |||||||
| 17 | class Fam |
||||||
| 18 | { |
||||||
| 19 | /** |
||||||
| 20 | * @param \PhpGedcom\Record\Fam $sour |
||||||
| 21 | * @param int $level |
||||||
| 22 | * |
||||||
| 23 | * @return string |
||||||
| 24 | */ |
||||||
| 25 | public static function convert(\PhpGedcom\Record\Fam &$fam, $level = 0) |
||||||
| 26 | { |
||||||
| 27 | $output = ''; |
||||||
| 28 | $id = $fam->getId(); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 29 | if (empty($id)) { |
||||||
| 30 | return $output; |
||||||
| 31 | } else { |
||||||
| 32 | $output .= $level.' @'.$id.'@ FAM '."\n"; |
||||||
|
0 ignored issues
–
show
Are you sure
$id of type PhpGedcom\Record\Fam|mixed can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 33 | } |
||||||
| 34 | // level up |
||||||
| 35 | $level++; |
||||||
| 36 | |||||||
| 37 | // HUSB |
||||||
| 38 | $husb = $fam->getHusb(); |
||||||
|
0 ignored issues
–
show
The method
getHusb() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 39 | if (!empty($husb)) { |
||||||
| 40 | $output .= $level.' HUSB @'.$husb."@\n"; |
||||||
|
0 ignored issues
–
show
Are you sure
$husb of type PhpGedcom\Record\Fam|mixed can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 41 | } |
||||||
| 42 | |||||||
| 43 | // WIFE |
||||||
| 44 | $wife = $fam->getWife(); |
||||||
|
0 ignored issues
–
show
The method
getWife() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 45 | if (!empty($wife)) { |
||||||
| 46 | $output .= $level.' WIFE @'.$wife."@\n"; |
||||||
|
0 ignored issues
–
show
Are you sure
$wife of type PhpGedcom\Record\Fam|mixed can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 47 | } |
||||||
| 48 | |||||||
| 49 | // CHIL |
||||||
| 50 | $chil = $fam->getChil(); |
||||||
|
0 ignored issues
–
show
The method
getChil() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 51 | if (!empty($chil) && count($chil) > 0) { |
||||||
|
0 ignored issues
–
show
It seems like
$chil can also be of type PhpGedcom\Record\Fam; however, parameter $var of count() does only seem to accept Countable|array, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 52 | foreach ($chil as $item) { |
||||||
| 53 | if ($item) { |
||||||
| 54 | $_convert = $level.' CHIL @'.$item."@\n"; |
||||||
| 55 | $output .= $_convert; |
||||||
| 56 | } |
||||||
| 57 | } |
||||||
| 58 | } |
||||||
| 59 | // NCHI |
||||||
| 60 | $nchi = $fam->getNchi(); |
||||||
|
0 ignored issues
–
show
The method
getNchi() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 61 | if (!empty($nchi)) { |
||||||
| 62 | $output .= $level.' NCHI '.$nchi."\n"; |
||||||
|
0 ignored issues
–
show
Are you sure
$nchi of type PhpGedcom\Record\Fam|mixed can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 63 | } |
||||||
| 64 | |||||||
| 65 | // SUBM array |
||||||
| 66 | $subm = $fam->getSubm(); |
||||||
|
0 ignored issues
–
show
The method
getSubm() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 67 | |||||||
| 68 | if (!empty($subm) && count($subm) > 0) { |
||||||
| 69 | foreach ($subm as $item) { |
||||||
| 70 | if ($item) { |
||||||
| 71 | $output .= $level.' SUBM '.$item."\n"; |
||||||
| 72 | } |
||||||
| 73 | } |
||||||
| 74 | } |
||||||
| 75 | |||||||
| 76 | // RIN |
||||||
| 77 | $rin = $fam->getRin(); |
||||||
|
0 ignored issues
–
show
The method
getRin() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 78 | if (!empty($rin)) { |
||||||
| 79 | $output .= $level.' RIN '.$rin."\n"; |
||||||
|
0 ignored issues
–
show
Are you sure
$rin of type PhpGedcom\Record\Fam|mixed can be used in concatenation?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 80 | } |
||||||
| 81 | // CHAN |
||||||
| 82 | $chan = $fam->getChan(); |
||||||
|
0 ignored issues
–
show
The method
getChan() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 83 | if (!empty($chan)) { |
||||||
| 84 | $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
||||||
|
0 ignored issues
–
show
It seems like
$chan can also be of type PhpGedcom\Record\Fam; however, parameter $chan of PhpGedcom\Writer\Chan::convert() does only seem to accept PhpGedcom\Record\Chan, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 85 | $output .= $_convert; |
||||||
| 86 | } |
||||||
| 87 | // SLGS |
||||||
| 88 | $slgs = $fam->getSlgs(); |
||||||
|
0 ignored issues
–
show
The method
getSlgs() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 89 | if (!empty($slgs) && count($slgs) > 0) { |
||||||
| 90 | if ($slgs) { |
||||||
| 91 | $_convert = \PhpGedcom\Writer\Fam\Slgs::convert($item, $level); |
||||||
| 92 | $output .= $_convert; |
||||||
| 93 | } |
||||||
| 94 | } |
||||||
| 95 | |||||||
| 96 | // REFN array |
||||||
| 97 | $refn = $fam->getRefn(); |
||||||
|
0 ignored issues
–
show
The method
getRefn() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 98 | if (!empty($refn) && count($refn) > 0) { |
||||||
| 99 | foreach ($refn as $item) { |
||||||
| 100 | if ($item) { |
||||||
| 101 | $_convert = \PhpGedcom\Writer\Refn::convert($item, $level); |
||||||
| 102 | $output .= $_convert; |
||||||
| 103 | } |
||||||
| 104 | } |
||||||
| 105 | } |
||||||
| 106 | |||||||
| 107 | // NOTE array |
||||||
| 108 | $note = $fam->getNote(); |
||||||
|
0 ignored issues
–
show
The method
getNote() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 109 | if (!empty($note) && count($note) > 0) { |
||||||
| 110 | foreach ($note as $item) { |
||||||
| 111 | if ($item) { |
||||||
| 112 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||||||
| 113 | $output .= $_convert; |
||||||
| 114 | } |
||||||
| 115 | } |
||||||
| 116 | } |
||||||
| 117 | |||||||
| 118 | // SOUR |
||||||
| 119 | $sour = $fam->getSour(); |
||||||
|
0 ignored issues
–
show
The method
getSour() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 120 | if (!empty($sour) && count($sour) > 0) { |
||||||
| 121 | foreach ($sour as $item) { |
||||||
| 122 | if ($item) { |
||||||
| 123 | $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level); |
||||||
| 124 | $output .= $_convert; |
||||||
| 125 | } |
||||||
| 126 | } |
||||||
| 127 | } |
||||||
| 128 | |||||||
| 129 | // OBJE |
||||||
| 130 | $obje = $fam->getObje(); |
||||||
|
0 ignored issues
–
show
The method
getObje() does not exist on PhpGedcom\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
Loading history...
|
|||||||
| 131 | if (!empty($obje) && count($obje) > 0) { |
||||||
| 132 | foreach ($obje as $item) { |
||||||
| 133 | if ($item) { |
||||||
| 134 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||||||
| 135 | $output .= $_convert; |
||||||
| 136 | } |
||||||
| 137 | } |
||||||
| 138 | } |
||||||
| 139 | |||||||
| 140 | // EVEN |
||||||
| 141 | $even = $fam->getAllEven(); |
||||||
| 142 | if (!empty($even) && count($even) > 0) { |
||||||
| 143 | foreach ($even as $item) { |
||||||
| 144 | if ($item) { |
||||||
| 145 | $_convert = \PhpGedcom\Writer\Fam\Even::convert($item, $level); |
||||||
| 146 | $output .= $_convert; |
||||||
| 147 | } |
||||||
| 148 | } |
||||||
| 149 | } |
||||||
| 150 | |||||||
| 151 | return $output; |
||||||
| 152 | } |
||||||
| 153 | } |
||||||
| 154 |