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