familytree365 /
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 Gedcom\Writer; |
||||
| 16 | |||||
| 17 | class Repo |
||||
| 18 | { |
||||
| 19 | /** |
||||
| 20 | * @param \Gedcom\Record\Repo $sour |
||||
| 21 | * @param int $level |
||||
| 22 | * |
||||
| 23 | * @return string |
||||
| 24 | */ |
||||
| 25 | public static function convert(\Gedcom\Record\Repo &$repo) |
||||
| 26 | { |
||||
| 27 | $level = 0; |
||||
| 28 | $output = ''; |
||||
| 29 | $_repo = $repo->getRepo(); |
||||
| 30 | if ($_repo) { |
||||
| 31 | $output .= $level.' '.$_repo." REPO\n"; |
||||
| 32 | } else { |
||||
| 33 | return $output; |
||||
| 34 | } |
||||
| 35 | |||||
| 36 | // level up |
||||
| 37 | $level++; |
||||
| 38 | |||||
| 39 | //NAME |
||||
| 40 | $name = $repo->getName(); |
||||
| 41 | if ($name) { |
||||
| 42 | $output .= $level.' NAME '.$name."\n"; |
||||
| 43 | } |
||||
| 44 | |||||
| 45 | // ADDR |
||||
| 46 | $addr = $repo->getAddr(); |
||||
| 47 | if ($addr) { |
||||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
| 48 | $_convert = \Gedcom\Writer\Addr::convert($addr, $level); |
||||
| 49 | $output .= $_convert; |
||||
| 50 | } |
||||
| 51 | |||||
| 52 | // PHON |
||||
| 53 | $phon = $repo->getPhon(); |
||||
| 54 | if ($phon) { |
||||
|
0 ignored issues
–
show
The expression
$phon of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||||
| 55 | $_convert = \Gedcom\Writer\Phon::convert($phon, $level); |
||||
|
0 ignored issues
–
show
$phon of type array is incompatible with the type string expected by parameter $phon of Gedcom\Writer\Phon::convert().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 56 | $output .= $_convert; |
||||
| 57 | } |
||||
| 58 | |||||
| 59 | // NOTE array |
||||
| 60 | $note = $repo->getNote(); |
||||
| 61 | if ($note && count($note) > 0) { |
||||
|
0 ignored issues
–
show
The expression
$note of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||||
| 62 | foreach ($note as $item) { |
||||
| 63 | if ($item) { |
||||
| 64 | $_convert = \Gedcom\Writer\NoteRef::convert($item, $level); |
||||
| 65 | $output .= $_convert; |
||||
| 66 | } |
||||
| 67 | } |
||||
| 68 | } |
||||
| 69 | |||||
| 70 | // REFN |
||||
| 71 | $refn = $repo->getRefn(); |
||||
| 72 | if (!empty($refn) && count($refn) > 0) { |
||||
| 73 | foreach ($refn as $item) { |
||||
| 74 | if ($item) { |
||||
| 75 | $_convert = \Gedcom\Writer\Refn::convert($item, $level); |
||||
| 76 | $output .= $_convert; |
||||
| 77 | } |
||||
| 78 | } |
||||
| 79 | } |
||||
| 80 | |||||
| 81 | // CHAN |
||||
| 82 | $chan = $repo->getChan(); |
||||
| 83 | if ($chan) { |
||||
|
0 ignored issues
–
show
|
|||||
| 84 | $_convert = \Gedcom\Writer\Chan::convert($chan, $level); |
||||
| 85 | $output .= $_convert; |
||||
| 86 | } |
||||
| 87 | |||||
| 88 | // RIN |
||||
| 89 | $rin = $repo->getRin(); |
||||
| 90 | if ($rin) { |
||||
| 91 | $output .= $level.' RIN '.$rin."\n"; |
||||
| 92 | } |
||||
| 93 | |||||
| 94 | return $output; |
||||
| 95 | } |
||||
| 96 | } |
||||
| 97 |