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 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 Sour |
||||
| 18 | { |
||||
| 19 | /** |
||||
| 20 | * @param \PhpGedcom\Record\Sour $sour |
||||
| 21 | * @param int $level |
||||
| 22 | * |
||||
| 23 | * @return string |
||||
| 24 | */ |
||||
| 25 | public static function convert(\PhpGedcom\Record\Sour &$sour, $level) |
||||
| 26 | { |
||||
| 27 | $output = ''; |
||||
| 28 | $_sour = $sour->getSour(); |
||||
| 29 | if (empty($_sour)) { |
||||
| 30 | return $output; |
||||
| 31 | } else { |
||||
| 32 | $output .= $level.' '.$_sour.' SOUR '."\n"; |
||||
| 33 | } |
||||
| 34 | // level up |
||||
| 35 | $level++; |
||||
| 36 | |||||
| 37 | // TITL |
||||
| 38 | $titl = $sour->getType(); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 39 | if (!empty($type)) { |
||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||
| 40 | $output .= $level.' TITL '.$titl."\n"; |
||||
|
0 ignored issues
–
show
Are you sure
$titl of type PhpGedcom\Record\Sour|mixed|null 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 | // RIN |
||||
| 44 | $rin = $sour->getRin(); |
||||
| 45 | if (!empty($rin)) { |
||||
| 46 | $output .= $level.' RIN '.$rin."\n"; |
||||
| 47 | } |
||||
| 48 | |||||
| 49 | // AUTH |
||||
| 50 | $auth = $sour->getAuth(); |
||||
| 51 | if (!empty($auth)) { |
||||
| 52 | $output .= $level.' AUTH '.$auth."\n"; |
||||
| 53 | } |
||||
| 54 | |||||
| 55 | // TEXT |
||||
| 56 | $text = $sour->getText(); |
||||
| 57 | if (!empty($text)) { |
||||
| 58 | $output .= $level.' TEXT '.$text."\n"; |
||||
| 59 | } |
||||
| 60 | |||||
| 61 | // PUBL |
||||
| 62 | $publ = $sour->getPubl(); |
||||
| 63 | if (!empty($publ)) { |
||||
| 64 | $output .= $level.' PUBL '.$publ."\n"; |
||||
| 65 | } |
||||
| 66 | |||||
| 67 | // ABBR |
||||
| 68 | $abbr = $sour->getAbbr(); |
||||
| 69 | if (!empty($abbr)) { |
||||
| 70 | $output .= $level.' ABBR '.$abbr."\n"; |
||||
| 71 | } |
||||
| 72 | |||||
| 73 | // REPO |
||||
| 74 | $repo = $sour->getRepo(); |
||||
| 75 | if (!empty($repo)) { |
||||
| 76 | $_convert = \PhpGedcom\Writer\RepoRef::convert($repo, $level); |
||||
|
0 ignored issues
–
show
$repo of type PhpGedcom\Record\Repo is incompatible with the type PhpGedcom\Record\RepoRef expected by parameter $reporef of PhpGedcom\Writer\RepoRef::convert().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 77 | $output .= $_convert; |
||||
| 78 | } |
||||
| 79 | |||||
| 80 | // NOTE array |
||||
| 81 | $note = $sour->getNote(); |
||||
| 82 | if (!empty($note) && count($note) > 0) { |
||||
| 83 | foreach ($note as $item) { |
||||
| 84 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||||
| 85 | $output .= $_convert; |
||||
| 86 | } |
||||
| 87 | } |
||||
| 88 | |||||
| 89 | // DATA |
||||
| 90 | $data = $sour->getData(); |
||||
| 91 | if (!empty($data)) { |
||||
| 92 | $_convert = \PhpGedcom\Writer\Sour\Data::convert($data, $level); |
||||
|
0 ignored issues
–
show
$data of type string is incompatible with the type PhpGedcom\Record\Sour\Data expected by parameter $data of PhpGedcom\Writer\Sour\Data::convert().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 93 | $output .= $_convert; |
||||
| 94 | } |
||||
| 95 | |||||
| 96 | // OBJE array |
||||
| 97 | $obje = $sour->getObje(); |
||||
| 98 | if (!empty($obje) && count($obje) > 0) { |
||||
| 99 | foreach ($obje as $item) { |
||||
| 100 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||||
| 101 | $output .= $_convert; |
||||
| 102 | } |
||||
| 103 | } |
||||
| 104 | |||||
| 105 | // REFN array |
||||
| 106 | $refn = $sour->getRefn(); |
||||
| 107 | if (!empty($refn) && count($refn) > 0) { |
||||
| 108 | foreach ($refn as $item) { |
||||
| 109 | $_convert = \PhpGedcom\Writer\Refn::convert($item, $level); |
||||
| 110 | $output .= $_convert; |
||||
| 111 | } |
||||
| 112 | } |
||||
| 113 | |||||
| 114 | // chan |
||||
| 115 | $chan = $sour->getChan(); |
||||
| 116 | if (!empty($chan)) { |
||||
| 117 | $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
||||
| 118 | $output .= $_convert; |
||||
| 119 | } |
||||
| 120 | |||||
| 121 | return $output; |
||||
| 122 | } |
||||
| 123 | } |
||||
| 124 |