diff --git a/.github/workflows/codescan.yml b/.github/workflows/codescan.yml new file mode 100644 index 00000000..88199fa9 --- /dev/null +++ b/.github/workflows/codescan.yml @@ -0,0 +1,49 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# This workflow requires that you have an existing account with codescan.io +# For more information about configuring your workflow, +# read our documentation at https://github.com/codescan-io/codescan-scanner-action +name: CodeScan + +on: + push: + branches: [ "master" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "master" ] + schedule: + - cron: '37 3 * * 6' + +permissions: + contents: read + +jobs: + CodeScan: + permissions: + contents: read # for actions/checkout to fetch code + security-events: write # for github/codeql-action/upload-sarif to upload SARIF results + actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Cache files + uses: actions/cache@v3 + with: + path: | + ~/.sonar + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Run Analysis + uses: codescan-io/codescan-scanner-action@5b2e8c5683ef6a5adc8fa3b7950bb07debccce12 + with: + login: ${{ secrets.CODESCAN_AUTH_TOKEN }} + organization: ${{ secrets.CODESCAN_ORGANIZATION_KEY }} + projectKey: ${{ secrets.CODESCAN_PROJECT_KEY }} + - name: Upload SARIF file + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: codescan.sarif diff --git a/README.md b/README.md index 797a99e3..d4565af8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ To install php-gedcom in your project using composer, simply add the following r { "require": { - "oguz463/php-gedcom": "1.0.*" + "tlesseli/php-gedcom": "1.0.*" } } diff --git a/composer.json b/composer.json index 81d3d2c8..6f6ced80 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "oguz463/php-gedcom", + "name": "tlesseli/php-gedcom", "description": "A GEDCOM file parser (read + write) for PHP 5.3+", "type": "library", "keywords": ["gedcom","parser"], diff --git a/library/PhpGedcom/Parser.php b/library/PhpGedcom/Parser.php index eb22212e..6773065b 100644 --- a/library/PhpGedcom/Parser.php +++ b/library/PhpGedcom/Parser.php @@ -17,318 +17,302 @@ /** * */ -class Parser -{ - /** - * - */ - protected $_file = null; - - /** - * - */ - protected $_gedcom = null; - - /** - * - */ - protected $_errorLog = array(); - - /** - * - */ - protected $_linesParsed = 0; - - /** - * - */ - protected $_line = ''; - - /** - * - */ - protected $_lineRecord = null; - - /** - * - */ - protected $_linePices = 0; - - /** - * - */ - protected $_returnedLine = ''; - - /** - * - */ - public function __construct(\PhpGedcom\Gedcom $gedcom = null) - { - if (!is_null($gedcom)) { - $this->_gedcom = $gedcom; - } else { - $this->_gedcom = new \PhpGedcom\Gedcom(); - } - } - - /** - * - */ - public function forward() - { - // if there was a returned line by back(), set that as our current - // line and blank out the returnedLine variable, otherwise grab - // the next line from the file - - if (!empty($this->_returnedLine)) { - $this->_line = $this->_returnedLine; - $this->_returnedLine = ''; - } else { - $this->_line = fgets($this->_file); - $this->_lineRecord = null; - $this->_linesParsed++; - } - - return $this; - } - - /** - * - */ - public function back() - { - // our parser object encountered a line it wasn't meant to parse - // store this line for the previous parser to analyze - - $this->_returnedLine = $this->_line; - - return $this; - } - - /** - * Jump to the next level in the GEDCOM that is <= $level. This will leave the parser at the line above - * this level, such that calling $parser->forward() will result in landing at the correct level. - * - * @param int $level - */ - public function skipToNextLevel($level) - { - $currentDepth = 999; - - while ($currentDepth > $level) { - $this->forward(); - $record = $this->getCurrentLineRecord(); - $currentDepth = (int)$record[0]; - } - - $this->back(); - } - - /** - * - */ - public function getGedcom() - { - return $this->_gedcom; - } - - /** - * - */ - public function eof() - { - return feof($this->_file); - } - - /** - * - * @return string - */ - public function parseMultiLineRecord() - { - $record = $this->getCurrentLineRecord(); - - $depth = (int)$record[0]; - $data = isset($record[2]) ? trim($record[2]) : ''; - - $this->forward(); - - while (!$this->eof()) { - $record = $this->getCurrentLineRecord(); - $recordType = strtoupper(trim($record[1])); - $currentDepth = (int)$record[0]; - - if ($currentDepth <= $depth) { - $this->back(); - break; - } - - switch ($recordType) { - case 'CONT': - $data .= "\n"; - - if (isset($record[2])) { - $data .= trim($record[2]); - } - break; - case 'CONC': - if (isset($record[2])) { - $data .= ' ' . trim($record[2]); - } - break; - default: - $this->back(); - break 2; - } - - $this->forward(); - } - - return $data; - } - - /** - * - * @return string The current line - */ - public function getCurrentLine() - { - return $this->_line; - } - - /** - * - */ - public function getCurrentLineRecord($pieces = 3) - { - if (!is_null($this->_lineRecord)) { - if ($this->_linePieces == $pieces) { - return $this->_lineRecord; - } - } - - if (empty($this->_line)) { - return false; - } - - $line = trim($this->_line); - - $this->_lineRecord = explode(' ', $line, $pieces); - $this->_linePieces = $pieces; - - return $this->_lineRecord; - } - - /** - * - */ - protected function logError($error) - { - $this->_errorLog[] = $error; - } - - /** - * - */ - public function logUnhandledRecord($additionalInfo = '') - { - $this->logError( - $this->_linesParsed . ': (Unhandled) ' . trim(implode('|', $this->getCurrentLineRecord())) . - (!empty($additionalInfo) ? ' - ' . $additionalInfo : '') - ); - } - - public function logSkippedRecord($additionalInfo = '') - { - $this->logError( - $this->_linesParsed . ': (Skipping) ' . trim(implode('|', $this->getCurrentLineRecord())) . - (!empty($additionalInfo) ? ' - ' . $additionalInfo : '') - ); - } - - /** - * - */ - public function getErrors() - { - return $this->_errorLog; - } - - /** - * - */ - public function normalizeIdentifier($identifier) - { - $identifier = trim($identifier); - $identifier = trim($identifier, '@'); - - return $identifier; - } - - /** - * - * @param string $fileName - * @return Gedcom - */ - public function parse($fileName) - { - $this->_file = fopen($fileName, 'r'); #explode("\n", mb_convert_encoding($contents, 'UTF-8')); - - if (!$this->_file) { - return null; - } - - $this->forward(); - - while (!$this->eof()) { - $record = $this->getCurrentLineRecord(); - - if ($record === false) { - continue; - } - - $depth = (int)$record[0]; - - // We only process 0 level records here. Sub levels are processed - // in methods for those data types (individuals, sources, etc) - - if ($depth == 0) { - // Although not always an identifier (HEAD,TRLR): - if(isset($record[1])) - $identifier = $this->normalizeIdentifier($record[1]); - - - if (isset($record[1]) && trim($record[1]) == 'HEAD') { - Parser\Head::parse($this); - } else if (isset($record[2]) && trim($record[2]) == 'SUBN') { - Parser\Subn::parse($this); - } else if (isset($record[2]) && trim($record[2]) == 'SUBM') { - Parser\Subm::parse($this); - } else if (isset($record[2]) && $record[2] == 'SOUR') { - Parser\Sour::parse($this); - } else if (isset($record[2]) && $record[2] == 'INDI') { - Parser\Indi::parse($this); - } else if (isset($record[2]) && $record[2] == 'FAM') { - Parser\Fam::parse($this); - } else if (isset($record[2]) && substr(trim($record[2]), 0, 4) == 'NOTE') { - Parser\Note::parse($this); - } else if (isset($record[2]) && $record[2] == 'REPO') { - Parser\Repo::parse($this); - } else if (isset($record[2]) && $record[2] == 'OBJE') { - Parser\Obje::parse($this); - } else if (isset($record[1]) && trim($record[1]) == 'TRLR') { - // EOF - break; - } else { - $this->logUnhandledRecord(get_class() . ' @ ' . __LINE__); - } - } else { - $this->logUnhandledRecord(get_class() . ' @ ' . __LINE__); - } - - $this->forward(); - } - - return $this->getGedcom(); - } +class Parser { + /** + * + */ + protected $_file = null; + + /** + * + */ + protected $_gedcom = null; + + /** + * + */ + protected $_errorLog = array(); + + /** + * + */ + protected $_linesParsed = 0; + + /** + * + */ + protected $_line = ''; + + /** + * + */ + protected $_lineRecord = null; + + /** + * + */ + protected $_linePieces = 0; + + /** + * + */ + protected $_returnedLine = ''; + + /** + * + */ + public function __construct(\PhpGedcom\Gedcom $gedcom = null) { + if (!is_null($gedcom)) { + $this->_gedcom = $gedcom; + } else { + $this->_gedcom = new \PhpGedcom\Gedcom(); + } + } + + /** + * + */ + public function forward() { + // if there was a returned line by back(), set that as our current + // line and blank out the returnedLine variable, otherwise grab + // the next line from the file + + if (!empty($this->_returnedLine)) { + $this->_line = $this->_returnedLine; + $this->_returnedLine = ''; + } else { + $this->_line = fgets($this->_file); + $this->_lineRecord = null; + $this->_linesParsed++; + } + + return $this; + } + + /** + * + */ + public function back() { + // our parser object encountered a line it wasn't meant to parse + // store this line for the previous parser to analyze + + $this->_returnedLine = $this->_line; + + return $this; + } + + /** + * Jump to the next level in the GEDCOM that is <= $level. This will leave the parser at the line above + * this level, such that calling $parser->forward() will result in landing at the correct level. + * + * @param int $level + */ + public function skipToNextLevel($level) { + $currentDepth = 999; + + while ($currentDepth > $level) { + $this->forward(); + $record = $this->getCurrentLineRecord(); + $currentDepth = (int) $record[0]; + } + + $this->back(); + } + + /** + * + */ + public function getGedcom() { + return $this->_gedcom; + } + + /** + * + */ + public function eof() { + return feof($this->_file); + } + + /** + * + * @return string + */ + public function parseMultiLineRecord() { + $record = $this->getCurrentLineRecord(); + + $depth = (int) $record[0]; + $data = isset($record[2]) ? trim($record[2]) : ''; + + $this->forward(); + + while (!$this->eof()) { + $record = $this->getCurrentLineRecord(); + $recordType = strtoupper(trim($record[1])); + $currentDepth = (int) $record[0]; + + if ($currentDepth <= $depth) { + $this->back(); + break; + } + + switch ($recordType) { + case 'CONT': + $data .= "\n"; + + if (isset($record[2])) { + $data .= trim($record[2]); + } + break; + case 'CONC': + if (isset($record[2])) { + $data .= ' ' . trim($record[2]); + } + break; + default: + $this->back(); + break 2; + } + + $this->forward(); + } + + return $data; + } + + /** + * + * @return string The current line + */ + public function getCurrentLine() { + return $this->_line; + } + + /** + * + */ + public function getCurrentLineRecord($pieces = 3) { + if (!is_null($this->_lineRecord)) { + if ($this->_linePieces == $pieces) { + return $this->_lineRecord; + } + } + + if (empty($this->_line)) { + return false; + } + + $line = trim($this->_line); + + $this->_lineRecord = explode(' ', $line, $pieces); + $this->_linePieces = $pieces; + + return $this->_lineRecord; + } + + /** + * + */ + protected function logError($error) { + $this->_errorLog[] = $error; + } + + /** + * + */ + public function logUnhandledRecord($additionalInfo = '') { + $this->logError( + $this->_linesParsed . ': (Unhandled) ' . trim(implode('|', $this->getCurrentLineRecord())) . + (!empty($additionalInfo) ? ' - ' . $additionalInfo : '') + ); + } + + public function logSkippedRecord($additionalInfo = '') { + $this->logError( + $this->_linesParsed . ': (Skipping) ' . trim(implode('|', $this->getCurrentLineRecord())) . + (!empty($additionalInfo) ? ' - ' . $additionalInfo : '') + ); + } + + /** + * + */ + public function getErrors() { + return $this->_errorLog; + } + + /** + * + */ + public function normalizeIdentifier($identifier) { + $identifier = trim($identifier); + $identifier = trim($identifier, '@'); + + return $identifier; + } + + /** + * + * @param string $fileName + * @return Gedcom + */ + public function parse($fileName) { + $this->_file = fopen($fileName, 'r'); #explode("\n", mb_convert_encoding($contents, 'UTF-8')); + + if (!$this->_file) { + return null; + } + + $this->forward(); + + while (!$this->eof()) { + $record = $this->getCurrentLineRecord(); + + if ($record === false) { + continue; + } + + $depth = (int) $record[0]; + + // We only process 0 level records here. Sub levels are processed + // in methods for those data types (individuals, sources, etc) + + if ($depth == 0) { + // Although not always an identifier (HEAD,TRLR): + if (isset($record[1])) { + $identifier = $this->normalizeIdentifier($record[1]); + } + + if (isset($record[1]) && trim($record[1]) == 'HEAD') { + Parser\Head::parse($this); + } else if (isset($record[2]) && trim($record[2]) == 'SUBN') { + Parser\Subn::parse($this); + } else if (isset($record[2]) && trim($record[2]) == 'SUBM') { + Parser\Subm::parse($this); + } else if (isset($record[2]) && $record[2] == 'SOUR') { + Parser\Sour::parse($this); + } else if (isset($record[2]) && $record[2] == 'INDI') { + Parser\Indi::parse($this); + } else if (isset($record[2]) && $record[2] == 'FAM') { + Parser\Fam::parse($this); + } else if (isset($record[2]) && substr(trim($record[2]), 0, 4) == 'NOTE') { + Parser\Note::parse($this); + } else if (isset($record[2]) && $record[2] == 'REPO') { + Parser\Repo::parse($this); + } else if (isset($record[2]) && $record[2] == 'OBJE') { + Parser\Obje::parse($this); + } else if (isset($record[1]) && trim($record[1]) == 'TRLR') { + // EOF + break; + } else { + $this->logUnhandledRecord(get_class() . ' @ ' . __LINE__); + } + } else { + $this->logUnhandledRecord(get_class() . ' @ ' . __LINE__); + } + + $this->forward(); + } + + return $this->getGedcom(); + } } diff --git a/library/PhpGedcom/Parser/Date.php b/library/PhpGedcom/Parser/Date.php new file mode 100644 index 00000000..ac46d390 --- /dev/null +++ b/library/PhpGedcom/Parser/Date.php @@ -0,0 +1,42 @@ + + * @copyright Copyright (c) 2010-2013, Kristopher Wilson + * @package php-gedcom + * @license GPL-3.0 + * @link http://github.com/mrkrstphr/php-gedcom + */ + +namespace PhpGedcom\Parser; + +/** + * + * + */ +class Date extends \PhpGedcom\Parser\Component { + + /** + * + * + */ + public static function parse(\PhpGedcom\Parser $parser) { + $record = $parser->getCurrentLineRecord(); + $depth = (int) $record[0]; + if (isset($record[1])) { + $dat = new \PhpGedcom\Record\Date(); + if (!empty($record[2])) { + $dat->setDate($record[2]); + } + } else { + $parser->skipToNextLevel($depth); + return null; + } + + return $dat; + } +} \ No newline at end of file diff --git a/library/PhpGedcom/Parser/Fam/Even.php b/library/PhpGedcom/Parser/Fam/Even.php index 06aa3beb..1f32d7b7 100644 --- a/library/PhpGedcom/Parser/Fam/Even.php +++ b/library/PhpGedcom/Parser/Fam/Even.php @@ -18,93 +18,93 @@ * * */ -class Even extends \PhpGedcom\Parser\Component -{ +class Even extends \PhpGedcom\Parser\Component { - /** - * - * - */ - public static function parse(\PhpGedcom\Parser $parser) - { - $record = $parser->getCurrentLineRecord(); - $depth = (int)$record[0]; + /** + * + * + */ + public static function parse(\PhpGedcom\Parser $parser) { + $record = $parser->getCurrentLineRecord(); + $depth = (int) $record[0]; - $even = new \PhpGedcom\Record\Fam\Even(); + $even = new \PhpGedcom\Record\Fam\Even(); - if (isset($record[1]) && strtoupper(trim($record[1])) != 'EVEN') { - $even->setType(trim($record[1])); - } + if (isset($record[1]) && strtoupper(trim($record[1])) != 'EVEN') { + $even->setType(trim($record[1])); + } - $parser->forward(); + $parser->forward(); - while (!$parser->eof()) { - $record = $parser->getCurrentLineRecord(); - $recordType = strtoupper(trim($record[1])); - $currentDepth = (int)$record[0]; + while (!$parser->eof()) { + $record = $parser->getCurrentLineRecord(); + $recordType = strtoupper(trim($record[1])); + $currentDepth = (int) $record[0]; - if ($currentDepth <= $depth) { - $parser->back(); - break; - } + if ($currentDepth <= $depth) { + $parser->back(); + break; + } - switch ($recordType) { - case 'TYPE': - $even->setType(trim($record[2])); - break; - case 'DATE': - $even->setDate(trim($record[2])); - break; - case 'PLAC': - $plac = \PhpGedcom\Parser\Indi\Even\Plac::parse($parser); - $even->setPlac($plac); - break; - case 'ADDR': - $addr = \PhpGedcom\Parser\Addr::parse($parser); - $even->setAddr($addr); - break; - case 'PHON': - $phone = \PhpGedcom\Parser\Phon::parse($parser); - $even->addPhone($phone); - break; - case 'CAUS': - $even->setCaus(trim($record[2])); - break; - case 'AGE': - $even->setAge(trim($record[2])); - break; - case 'AGNC': - $even->setAgnc(trim($record[2])); - break; - case 'HUSB': - $husb = \PhpGedcom\Parser\Fam\Even\Husb::parse($parser); - $even->setHusb($husb); - break; - case 'WIFE': - $wife = \PhpGedcom\Parser\Fam\Even\Wife::parse($parser); - $even->setWife($wife); - break; - case 'SOUR': - $sour = \PhpGedcom\Parser\SourRef::parse($parser); - $even->addSour($sour); - break; - case 'OBJE': - $obje = \PhpGedcom\Parser\ObjeRef::parse($parser); - $even->addObje($obje); - break; - case 'NOTE': - $note = \PhpGedcom\Parser\NoteRef::parse($parser); - if ($note) { - $even->addNote($note); - } - break; - default: - $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__); - } + switch ($recordType) { + case 'TYPE': + $even->setType(trim($record[2])); + break; + case 'DATE': + $dat = \PhpGedcom\Parser\Date::parse($parser); + $even->setDate($dat); + //$even->setDate(trim($record[2])); + break; + case 'PLAC': + $plac = \PhpGedcom\Parser\Indi\Even\Plac::parse($parser); + $even->setPlac($plac); + break; + case 'ADDR': + $addr = \PhpGedcom\Parser\Addr::parse($parser); + $even->setAddr($addr); + break; + case 'PHON': + $phone = \PhpGedcom\Parser\Phon::parse($parser); + $even->addPhone($phone); + break; + case 'CAUS': + $even->setCaus(trim($record[2])); + break; + case 'AGE': + $even->setAge(trim($record[2])); + break; + case 'AGNC': + $even->setAgnc(trim($record[2])); + break; + case 'HUSB': + $husb = \PhpGedcom\Parser\Fam\Even\Husb::parse($parser); + $even->setHusb($husb); + break; + case 'WIFE': + $wife = \PhpGedcom\Parser\Fam\Even\Wife::parse($parser); + $even->setWife($wife); + break; + case 'SOUR': + $sour = \PhpGedcom\Parser\SourRef::parse($parser); + $even->addSour($sour); + break; + case 'OBJE': + $obje = \PhpGedcom\Parser\ObjeRef::parse($parser); + $even->addObje($obje); + break; + case 'NOTE': + $note = \PhpGedcom\Parser\NoteRef::parse($parser); + if ($note) { + $even->addNote($note); + } + break; + default: + $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__); + } - $parser->forward(); - } + $parser->forward(); + } - return $even; - } + return $even; + } } diff --git a/library/PhpGedcom/Parser/Indi.php b/library/PhpGedcom/Parser/Indi.php index eb6ba70b..9cd5f41b 100644 --- a/library/PhpGedcom/Parser/Indi.php +++ b/library/PhpGedcom/Parser/Indi.php @@ -18,179 +18,176 @@ * * */ -class Indi extends \PhpGedcom\Parser\Component -{ - /** - * - * - */ - public static function parse(\PhpGedcom\Parser $parser) - { - $record = $parser->getCurrentLineRecord(); - $depth = (int)$record[0]; - if(isset($record[1])){ - $identifier = $parser->normalizeIdentifier($record[1]); - } - else{ - $parser->skipToNextLevel($depth); - return null; - } +class Indi extends \PhpGedcom\Parser\Component { + /** + * + * + */ + public static function parse(\PhpGedcom\Parser $parser) { + $record = $parser->getCurrentLineRecord(); + $depth = (int) $record[0]; + if (isset($record[1])) { + $identifier = $parser->normalizeIdentifier($record[1]); + } else { + $parser->skipToNextLevel($depth); + return null; + } - $indi = new \PhpGedcom\Record\Indi(); - $indi->setId($identifier); + $indi = new \PhpGedcom\Record\Indi(); + $indi->setId($identifier); - $parser->getGedcom()->addIndi($indi); + $parser->getGedcom()->addIndi($indi); - $parser->forward(); + $parser->forward(); - while (!$parser->eof()) { - $record = $parser->getCurrentLineRecord(); - $recordType = strtoupper(trim($record[1])); - $currentDepth = (int)$record[0]; + while (!$parser->eof()) { + $record = $parser->getCurrentLineRecord(); + $recordType = strtoupper(trim($record[1])); + $currentDepth = (int) $record[0]; - if ($currentDepth <= $depth) { - $parser->back(); - break; - } + if ($currentDepth <= $depth) { + $parser->back(); + break; + } - switch ($recordType) { - case '_UID': - $indi->setUid(trim($record[2])); - break; - case 'NAME': - $name = \PhpGedcom\Parser\Indi\Name::parse($parser); - $indi->addName($name); - break; - case 'ALIA': - $indi->addAlia($parser->normalizeIdentifier($record[2])); - break; - case 'SEX': - $indi->setSex(trim($record[2])); - break; - case 'RIN': - $indi->setRin(trim($record[2])); - break; - case 'RESN': - $indi->setResn(trim($record[2])); - break; - case 'RFN': - $indi->setRfn(trim($record[2])); - break; - case 'AFN': - $indi->setAfn(trim($record[2])); - break; - case 'CHAN': - $chan = \PhpGedcom\Parser\Chan::parse($parser); - $indi->setChan($chan); - break; - case 'FAMS': - $fams = \PhpGedcom\Parser\Indi\Fams::parse($parser); - if ($fams) { - $indi->addFams($fams); - } - break; - case 'FAMC': - $famc = \PhpGedcom\Parser\Indi\Famc::parse($parser); - if ($famc) { - $indi->addFamc($famc); - } - break; - case 'ASSO': - $asso = \PhpGedcom\Parser\Indi\Asso::parse($parser); - $indi->addAsso($asso); - break; - case 'ANCI': - $indi->addAnci($parser->normalizeIdentifier($record[2])); - break; - case 'DESI': - $indi->addDesi($parser->normalizeIdentifier($record[2])); - break; - case 'SUBM': - $indi->addSubm($parser->normalizeIdentifier($record[2])); - break; - case 'REFN': - $ref = \PhpGedcom\Parser\Refn::parse($parser); - $indi->addRefn($ref); - break; - case 'BAPL': - case 'CONL': - case 'ENDL': - case 'SLGC': - $className = ucfirst(strtolower($recordType)); - $class = '\\PhpGedcom\\Parser\\Indi\\' . $className; + switch ($recordType) { + case '_UID': + $indi->setUid(trim($record[2])); + break; + case 'NAME': + $name = \PhpGedcom\Parser\Indi\Name::parse($parser); + $indi->addName($name); + break; + case 'ALIA': + $indi->addAlia($parser->normalizeIdentifier($record[2])); + break; + case 'SEX': + $indi->setSex(isset($record[2]) ? trim($record[2]) : ''); + break; + case 'RIN': + $indi->setRin(trim($record[2])); + break; + case 'RESN': + $indi->setResn(trim($record[2])); + break; + case 'RFN': + $indi->setRfn(trim($record[2])); + break; + case 'AFN': + $indi->setAfn(trim($record[2])); + break; + case 'CHAN': + $chan = \PhpGedcom\Parser\Chan::parse($parser); + $indi->setChan($chan); + break; + case 'FAMS': + $fams = \PhpGedcom\Parser\Indi\Fams::parse($parser); + if ($fams) { + $indi->addFams($fams); + } + break; + case 'FAMC': + $famc = \PhpGedcom\Parser\Indi\Famc::parse($parser); + if ($famc) { + $indi->addFamc($famc); + } + break; + case 'ASSO': + $asso = \PhpGedcom\Parser\Indi\Asso::parse($parser); + $indi->addAsso($asso); + break; + case 'ANCI': + $indi->addAnci($parser->normalizeIdentifier($record[2])); + break; + case 'DESI': + $indi->addDesi($parser->normalizeIdentifier($record[2])); + break; + case 'SUBM': + $indi->addSubm($parser->normalizeIdentifier($record[2])); + break; + case 'REFN': + $ref = \PhpGedcom\Parser\Refn::parse($parser); + $indi->addRefn($ref); + break; + case 'BAPL': + case 'CONL': + case 'ENDL': + case 'SLGC': + $className = ucfirst(strtolower($recordType)); + $class = '\\PhpGedcom\\Parser\\Indi\\' . $className; - $lds = $class::parse($parser); - $indi->{'set' . $recordType}($lds); - break; - case 'OBJE': - $obje = \PhpGedcom\Parser\ObjeRef::parse($parser); - $indi->addObje($obje); - break; - case 'NOTE': - $note = \PhpGedcom\Parser\NoteRef::parse($parser); - if ($note) { - $indi->addNote($note); - } - break; - case 'SOUR': - $sour = \PhpGedcom\Parser\SourRef::parse($parser); - $indi->addSour($sour); - break; - case 'ADOP': - case 'BIRT': - case 'BAPM': - case 'BARM': - case 'BASM': - case 'BLES': - case 'BURI': - case 'CENS': - case 'CHR': - case 'CHRA': - case 'CONF': - case 'CREM': - case 'DEAT': - case 'EMIG': - case 'FCOM': - case 'GRAD': - case 'IMMI': - case 'NATU': - case 'ORDN': - case 'RETI': - case 'PROB': - case 'WILL': - case 'EVEN': - $className = ucfirst(strtolower($recordType)); - $class = '\\PhpGedcom\\Parser\\Indi\\' . $className; + $lds = $class::parse($parser); + $indi->{'set' . $recordType}($lds); + break; + case 'OBJE': + $obje = \PhpGedcom\Parser\ObjeRef::parse($parser); + $indi->addObje($obje); + break; + case 'NOTE': + $note = \PhpGedcom\Parser\NoteRef::parse($parser); + if ($note) { + $indi->addNote($note); + } + break; + case 'SOUR': + $sour = \PhpGedcom\Parser\SourRef::parse($parser); + $indi->addSour($sour); + break; + case 'ADOP': + case 'BIRT': + case 'BAPM': + case 'BARM': + case 'BASM': + case 'BLES': + case 'BURI': + case 'CENS': + case 'CHR': + case 'CHRA': + case 'CONF': + case 'CREM': + case 'DEAT': + case 'EMIG': + case 'FCOM': + case 'GRAD': + case 'IMMI': + case 'NATU': + case 'ORDN': + case 'RETI': + case 'PROB': + case 'WILL': + case 'EVEN': + $className = ucfirst(strtolower($recordType)); + $class = '\\PhpGedcom\\Parser\\Indi\\' . $className; - $event = $class::parse($parser); - $indi->addEven($event); - break; - case 'CAST': - case 'DSCR': - case 'EDUC': - case 'IDNO': - case 'NATI': - case 'NCHI': - case 'NMR': - case 'OCCU': - case 'PROP': - case 'RELI': - case 'RESI': - case 'SSN': - case 'TITL': - $className = ucfirst(strtolower($recordType)); - $class = '\\PhpGedcom\\Parser\\Indi\\' . $className; + $event = $class::parse($parser); + $indi->addEven($event); + break; + case 'CAST': + case 'DSCR': + case 'EDUC': + case 'IDNO': + case 'NATI': + case 'NCHI': + case 'NMR': + case 'OCCU': + case 'PROP': + case 'RELI': + case 'RESI': + case 'SSN': + case 'TITL': + $className = ucfirst(strtolower($recordType)); + $class = '\\PhpGedcom\\Parser\\Indi\\' . $className; - $att = $class::parse($parser); - $indi->addAttr($att); - break; - default: - $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__); - } + $att = $class::parse($parser); + $indi->addAttr($att); + break; + default: + $parser->logUnhandledRecord(get_class() . ' @ ' . __LINE__); + } - $parser->forward(); - } + $parser->forward(); + } - return $indi; - } + return $indi; + } } diff --git a/library/PhpGedcom/Parser/Indi/Even.php b/library/PhpGedcom/Parser/Indi/Even.php index 77cdd2e1..0851a629 100644 --- a/library/PhpGedcom/Parser/Indi/Even.php +++ b/library/PhpGedcom/Parser/Indi/Even.php @@ -20,107 +20,107 @@ * * */ -class Even extends \PhpGedcom\Parser\Component -{ +class Even extends \PhpGedcom\Parser\Component { - /** - * - * - */ - public static function parse(\PhpGedcom\Parser $parser) - { - $record = $parser->getCurrentLineRecord(); - $depth = (int)$record[0]; - if(empty($record[1])){ - $parser->skipToNextLevel($depth); - return null; - } + /** + * + * + */ + public static function parse(\PhpGedcom\Parser $parser) { + $record = $parser->getCurrentLineRecord(); + $depth = (int) $record[0]; + if (empty($record[1])) { + $parser->skipToNextLevel($depth); + return null; + } - $even = null; + $even = null; - if (strtoupper(trim($record[1])) != 'EVEN') { - $className = '\\PhpGedcom\\Record\\Indi\\' . ucfirst(strtolower(trim($record[1]))); - $even = new $className(); - } else { - $even = new \PhpGedcom\Record\Indi\Even(); - } + if (strtoupper(trim($record[1])) != 'EVEN') { + $className = '\\PhpGedcom\\Record\\Indi\\' . ucfirst(strtolower(trim($record[1]))); + $even = new $className(); + } else { + $even = new \PhpGedcom\Record\Indi\Even(); + } - if (isset($record[1]) && strtoupper(trim($record[1])) != 'EVEN') { - $even->setType(trim($record[1])); - } + if (isset($record[1]) && strtoupper(trim($record[1])) != 'EVEN') { + $even->setType(trim($record[1])); + } - $parser->forward(); + $parser->forward(); - while (!$parser->eof()) { - $record = $parser->getCurrentLineRecord(); - $recordType = strtoupper(trim($record[1])); - $currentDepth = (int)$record[0]; + while (!$parser->eof()) { + $record = $parser->getCurrentLineRecord(); + $recordType = strtoupper(trim($record[1])); + $currentDepth = (int) $record[0]; - if ($currentDepth <= $depth) { - $parser->back(); - break; - } + if ($currentDepth <= $depth) { + $parser->back(); + break; + } - switch ($recordType) { - case 'TYPE': - $even->setType(trim($record[2])); - break; - case 'DATE': - $even->setDate(trim($record[2])); - break; - case 'PLAC': - $plac = \PhpGedcom\Parser\Indi\Even\Plac::parse($parser); - $even->setPlac($plac); - break; - case 'ADDR': - $even->setAddr(\PhpGedcom\Parser\Addr::parse($parser)); - break; - case 'PHON': - $phone = \PhpGedcom\Parser\Phone::parse($parser); - $even->addPhone($phone); - break; - case 'CAUS': - $even->setCaus(trim($record[2])); - break; - case 'AGE': - $even->setAge(trim($record[2])); - break; - case 'AGNC': - $even->setAgnc(trim($record[2])); - break; - case 'SOUR': - $sour = \PhpGedcom\Parser\SourRef::parse($parser); - $even->addSour($sour); - break; - case 'OBJE': - $obje = \PhpGedcom\Parser\ObjeRef::parse($parser); - $even->addObje($obje); - break; - case 'NOTE': - $note = \PhpGedcom\Parser\NoteRef::parse($parser); - if ($note) { - $even->addNote($note); - } - break; - case 'CHAN': - $change = Chan::parse($parser); - $even->setChan($change); - break; - default: - $self = get_called_class(); - $method = 'parse' . $recordType; + switch ($recordType) { + case 'TYPE': + $even->setType(trim($record[2])); + break; + case 'DATE': + $dat = \PhpGedcom\Parser\Date::parse($parser); + $even->setDate($dat); + //$even->setDate(trim($record[2])) + break; + case 'PLAC': + $plac = \PhpGedcom\Parser\Indi\Even\Plac::parse($parser); + $even->setPlac($plac); + break; + case 'ADDR': + $even->setAddr(\PhpGedcom\Parser\Addr::parse($parser)); + break; + case 'PHON': + $phone = \PhpGedcom\Parser\Phon::parse($parser); + $even->addPhone($phone); + break; + case 'CAUS': + $even->setCaus(trim($record[2])); + break; + case 'AGE': + $even->setAge(trim($record[2])); + break; + case 'AGNC': + $even->setAgnc(trim($record[2])); + break; + case 'SOUR': + $sour = \PhpGedcom\Parser\SourRef::parse($parser); + $even->addSour($sour); + break; + case 'OBJE': + $obje = \PhpGedcom\Parser\ObjeRef::parse($parser); + $even->addObje($obje); + break; + case 'NOTE': + $note = \PhpGedcom\Parser\NoteRef::parse($parser); + if ($note) { + $even->addNote($note); + } + break; + case 'CHAN': + $change = Chan::parse($parser); + $even->setChan($change); + break; + default: + $self = get_called_class(); + $method = 'parse' . $recordType; - if (method_exists($self, $method)) { - $self::$method($parser, $even); - } else { - $parser->logUnhandledRecord($self . ' @ ' . __LINE__); - $parser->skipToNextLevel($currentDepth); - } - } + if (method_exists($self, $method)) { + $self::$method($parser, $even); + } else { + $parser->logUnhandledRecord($self . ' @ ' . __LINE__); + $parser->skipToNextLevel($currentDepth); + } + } - $parser->forward(); - } + $parser->forward(); + } - return $even; - } + return $even; + } } diff --git a/library/PhpGedcom/Record/Date.php b/library/PhpGedcom/Record/Date.php new file mode 100644 index 00000000..890aaeea --- /dev/null +++ b/library/PhpGedcom/Record/Date.php @@ -0,0 +1,125 @@ + + * @copyright Copyright (c) 2010-2013, Kristopher Wilson + * @package php-gedcom + * @license GPL-3.0 + * @link http://github.com/mrkrstphr/php-gedcom + */ + +namespace PhpGedcom\Record; + +use PhpGedcom\Record; + +/** + * Class Date + * @package PhpGedcom\Record + */ +class Date extends Record { + /** + * @var string + */ + protected $date = null; + + /** + * @var array + */ + private $months = [ + 'JAN' => 1, 'FEB' => 2, 'MAR' => 3, 'APR' => 4, 'MAY' => 5, 'JUN' => 6, + 'JUL' => 7, 'AUG' => 8, 'SEP' => 9, 'OCT' => 10, 'NOV' => 11, 'DEC' => 12, + ]; + + /** + * @param string $date Date array + * @return Date + */ + public function setDate($date) { + $this->date = $date; + + return $this; + } + + /** + * @return null|string + */ + public function getDate() { + return $this->date; + } + + /** + * Return month part of date + * + * @return int|null + */ + public function getMonth() { + $record = explode(' ', $this->date); + if (count($record) > 0) { + if ($this->isPrefix($record[0])) { + unset($record[0]); + } + foreach ($record as $part) { + if (isset($this->months[trim($part)])) { + return $this->months[trim($part)]; + } + } + } + + return null; + } + + /** + * Return year part of date + * + * @return int|null + */ + public function getYear() { + $record = explode(' ', $this->date); + if (count($record) > 0) { + if ($this->isPrefix($record[0])) { + unset($record[0]); + } + if (count($record) > 0) { + return (int) end($record); + } + } + + return null; + } + + /** + * Return day part of date + * + * @return int|null + */ + public function getDay() { + $record = explode(' ', $this->date); + if (!empty($record[0])) { + if ($this->isPrefix($record[0])) { + unset($record[0]); + } + if (count($record) > 0) { + $day = (int) reset($record); + if ($day >= 1 && $day <= 31) { + return $day; + } + } + } + + return null; + } + + /** + * Check if the first part is a prefix (eg 'BEF', 'ABT',). + * + * @param string $datePart Date part to be checked + * @return bool + */ + private function isPrefix($datePart) { + return in_array($datePart, ['FROM', 'TO', 'BEF', 'AFT', 'BET', 'AND', 'ABT', 'EST', 'CAL', 'INT']); + } +} \ No newline at end of file diff --git a/library/PhpGedcom/Record/Fam.php b/library/PhpGedcom/Record/Fam.php index 5ad42682..3b05742a 100644 --- a/library/PhpGedcom/Record/Fam.php +++ b/library/PhpGedcom/Record/Fam.php @@ -18,141 +18,134 @@ * * */ -class Fam extends \PhpGedcom\Record implements Noteable, Sourceable, Objectable -{ - /** - * - */ - protected $_id = null; - - /** - * - */ - protected $_chan = null; - - /** - * - */ - protected $_husb = null; - - /** - * - */ - protected $_wife = null; - - /** - * - */ - protected $_nchi = null; - - /** - * - */ - protected $_chil = array(); - - /** - * - */ - protected $_even = array(); - - /** - * - */ - protected $_slgs = array(); - - /** - * - */ - protected $_subm = array(); - - /** - * - */ - protected $_refn = array(); - - /** - * - */ - protected $_rin = null; - - /** - * - */ - protected $_note = array(); - - /** - * - */ - protected $_sour = array(); - - /** - * - */ - protected $_obje = array(); - - /** - * - */ - public function addEven($even = []) - { - $this->_even[$even->getType()] = $even; - } - - /** - * @return array - */ - public function getAllEven() - { - return $this->_even; - } - - /** - * @return array - */ - public function getEven($key = '') - { - if(isset($this->_even[strtoupper($key)])) - return $this->_even[strtoupper($key)]; - } - - /** - * - */ - public function addSlgs($slgs = []) - { - $this->_slgs[] = $slgs; - } - - /** - * - * - */ - public function addRefn($refn = []) - { - $this->_refn[] = $refn; - } - - /** - * - */ - public function addNote($note = []) - { - $this->_note[] = $note; - } - - /** - * - */ - public function addSour($sour = []) - { - $this->_sour[] = $sour; - } - - /** - * - */ - public function addObje($obje = []) - { - $this->_obje[] = $obje; - } +class Fam extends \PhpGedcom\Record implements Noteable, Sourceable, Objectable { + /** + * + */ + protected $_id = null; + + /** + * + */ + protected $_chan = null; + + /** + * + */ + protected $_husb = null; + + /** + * + */ + protected $_wife = null; + + /** + * + */ + protected $_nchi = null; + + /** + * + */ + protected $_chil = array(); + + /** + * + */ + protected $_even = array(); + + /** + * + */ + protected $_slgs = array(); + + /** + * + */ + protected $_subm = array(); + + /** + * + */ + protected $_refn = array(); + + /** + * + */ + protected $_rin = null; + + /** + * + */ + protected $_note = array(); + + /** + * + */ + protected $_sour = array(); + + /** + * + */ + protected $_obje = array(); + + /** + * + */ + public function addEven($even = []) { + $this->_even[$even->getType()] = $even; + } + + /** + * @return array + */ + public function getAllEven() { + return $this->_even; + } + /** + * @return void|\PhpGedcom\Record\Fam\Even + */ + public function getEven($key = '') { + if (isset($this->_even[strtoupper($key)])) { + return $this->_even[strtoupper($key)]; + } + + } + /** + + /** + * + */ + public function addSlgs($slgs = []) { + $this->_slgs[] = $slgs; + } + + /** + * + * + */ + public function addRefn($refn = []) { + $this->_refn[] = $refn; + } + + /** + * + */ + public function addNote($note = []) { + $this->_note[] = $note; + } + + /** + * + */ + public function addSour($sour = []) { + $this->_sour[] = $sour; + } + + /** + * + */ + public function addObje($obje = []) { + $this->_obje[] = $obje; + } } diff --git a/library/PhpGedcom/Record/Fam/Even.php b/library/PhpGedcom/Record/Fam/Even.php index 878a83e2..6d47684b 100644 --- a/library/PhpGedcom/Record/Fam/Even.php +++ b/library/PhpGedcom/Record/Fam/Even.php @@ -14,74 +14,74 @@ namespace PhpGedcom\Record\Fam; +use \PhpGedcom\Record\Noteable; use \PhpGedcom\Record\Objectable; use \PhpGedcom\Record\Sourceable; -use \PhpGedcom\Record\Noteable; /** * + * Event record. + * + * @method mixed getType() + * @method \PhpGedcom\Record\Date getDate() + * @method string getPlac() */ -class Even extends \PhpGedcom\Record implements Objectable, Sourceable, Noteable -{ - protected $_type = null; - protected $_date = null; - protected $_plac = null; - protected $_caus = null; - protected $_age = null; +class Even extends \PhpGedcom\Record implements Objectable, Sourceable, Noteable { + protected $_type = null; + protected $_date = null; + protected $_plac = null; + protected $_caus = null; + protected $_age = null; - protected $_addr = null; + protected $_addr = null; - protected $_phon = array(); + protected $_phon = array(); - protected $_agnc = null; + protected $_agnc = null; - protected $_husb = null; - protected $_wife = null; + protected $_husb = null; + protected $_wife = null; - /** - * - */ - protected $_obje = array(); + /** + * + */ + protected $_obje = array(); - /** - * - */ - protected $_sour = array(); + /** + * + */ + protected $_sour = array(); - /** - * - */ - protected $_note = array(); + /** + * + */ + protected $_note = array(); - /** - * - */ - public function addPhon($phon = []) - { - $this->_phon[] = $phon; - } + /** + * + */ + public function addPhon($phon = []) { + $this->_phon[] = $phon; + } - /** - * - */ - public function addObje($obje = []) - { - $this->_obje[] = $obje; - } + /** + * + */ + public function addObje($obje = []) { + $this->_obje[] = $obje; + } - /** - * - */ - public function addSour($sour = []) - { - $this->_sour[] = $sour; - } + /** + * + */ + public function addSour($sour = []) { + $this->_sour[] = $sour; + } - /** - * - */ - public function addNote($note = []) - { - $this->_note[] = $note; - } + /** + * + */ + public function addNote($note = []) { + $this->_note[] = $note; + } } diff --git a/library/PhpGedcom/Record/Head/Gedc.php b/library/PhpGedcom/Record/Head/Gedc.php index 14a6dd0b..0ebe7c77 100644 --- a/library/PhpGedcom/Record/Head/Gedc.php +++ b/library/PhpGedcom/Record/Head/Gedc.php @@ -7,7 +7,7 @@ * * @author Kristopher Wilson * @copyright Copyright (c) 2010-2013, Kristopher Wilson - * @package php-gedcom + * @package php-gedcom * @license GPL-3.0 * @link http://github.com/mrkrstphr/php-gedcom */ @@ -17,15 +17,46 @@ /** * */ -class Gedc extends \PhpGedcom\Record -{ - /** - * - */ - protected $_vers = null; - - /** - * - */ - protected $_form = null; +class Gedc extends \PhpGedcom\Record { + /** + * + */ + protected $_vers = null; + + /** + * + */ + protected $_form = null; + + /** + * + * @return Gedc/version + */ + public function getVersion() { + return $this->_vers; + } + + /** + * + * @param Gedc/version + */ + public function setVersion($vers = []) { + $this->_vers = $vers; + } + + /** + * + * @return Gedc/form + */ + public function getForm() { + return $this->_form; + } + + /** + * + * @param Gedc/version + */ + public function setForm($form = []) { + $this->_form = $form; + } } diff --git a/library/PhpGedcom/Record/Head/Sour.php b/library/PhpGedcom/Record/Head/Sour.php index c3dfc6f6..739e6d8e 100644 --- a/library/PhpGedcom/Record/Head/Sour.php +++ b/library/PhpGedcom/Record/Head/Sour.php @@ -17,66 +17,94 @@ /** * */ -class Sour extends \PhpGedcom\Record -{ - /** - * - */ - protected $_sour = null; +class Sour extends \PhpGedcom\Record { + /** + * + */ + protected $_sour = null; - /** - * - */ - protected $_vers = null; + /** + * + */ + protected $_vers = null; - /** - * - */ - protected $_name = null; + /** + * + */ + protected $_name = null; - /** - * - */ - protected $_corp = null; + /** + * + */ + protected $_corp = null; - /** - * - */ - protected $_data = null; + /** + * + */ + protected $_data = null; - /** - * - * @param Sour\Corp $corp - */ - public function setCorp($corp = []) - { - $this->_corp = $corp; - } + /** + * + * @param Sour\Corp $corp + */ + public function setCorp($corp = []) { + $this->_corp = $corp; + } - /** - * - * @return Sour\Corp - */ - public function getCorp() - { - return $this->_corp; - } + /** + * + * @return Sour\Corp + */ + public function getCorp() { + return $this->_corp; + } - /** - * - * @param \PhpGedcom\Record\Head\Sour\Data $data - */ - public function setData($data = []) - { - $this->_data = $data; - } + /** + * + * @param \PhpGedcom\Record\Head\Sour\Data $data + */ + public function setData($data = []) { + $this->_data = $data; + } + + /** + * + * @return \PhpGedcom\Record\Head\Sour\Data + */ + public function getData() { + return $this->_data; + } + + /** + * + * @return Sour\Name + */ + public function getName() { + return $this->_name; + } + + /** + * + * @param Sour\Name + */ + public function setName($name = []) { + $this->_name = $name; + } + + /** + * + * @return Sour\Version + */ + public function getVersion() { + return $this->_vers; + } + + /** + * + * @param Sour\Version + */ + public function setVersion($version = []) { + $this->_vers = $version; + } - /** - * - * @return \PhpGedcom\Record\Head\Sour\Data - */ - public function getData() - { - return $this->_data; - } } diff --git a/library/PhpGedcom/Record/Indi.php b/library/PhpGedcom/Record/Indi.php index 16efa4dd..8bdea74c 100644 --- a/library/PhpGedcom/Record/Indi.php +++ b/library/PhpGedcom/Record/Indi.php @@ -24,633 +24,580 @@ * Class Indi * @package PhpGedcom\Record */ -class Indi extends Record implements Noteable, Objectable, Sourceable -{ - /** - * @var string - */ - protected $id; - - /** - * @var string - */ - protected $uid; - - /** - * @var string - */ - protected $chan; - - /** - * @var Indi\Attr[] - */ - protected $attr = array(); - - /** - * @var Indi\Even[] - */ - protected $even = array(); - - /** - * @var Indi\Note[] - */ - protected $note = array(); - - /** - * @var Obje[] - */ - protected $obje = array(); - - /** - * @var Sour[] - */ - protected $sour = array(); - - /** - * @var Indi\Name[] - */ - protected $name = array(); - - /** - * @var string[] - */ - protected $alia = array(); - - /** - * @var string - */ - protected $sex; - - /** - * @var string - */ - protected $rin; - - /** - * @var string - */ - protected $resn; - - /** - * @var string - */ - protected $rfn; - - /** - * @var string - */ - protected $afn; - - /** - * @var Indi\Fams[] - */ - protected $fams = array(); - - /** - * @var Indi\Famc[] - */ - protected $famc = array(); - - /** - * @var Indi\Asso[] - */ - protected $asso = array(); - - /** - * @var string[] - */ - protected $subm = array(); - - /** - * @var string[] - */ - protected $anci = array(); - - /** - * @var string[] - */ - protected $desi = array(); - - /** - * @var Refn[] - */ - protected $refn = array(); - - /** - * @var Indi\Bapl - */ - protected $bapl; - - /** - * @var Indi\Conl - */ - protected $conl; - - /** - * @var Indi\Endl - */ - protected $endl; - - /** - * @var Indi\Slgc - */ - protected $slgc; - - /** - * @param string $id - * @return Indi - */ - public function setId($id = '') - { - $this->id = $id; - return $this; - } - - /** - * @return string - */ - public function getId() - { - return $this->id; - } - - /** - * @param string $uid - * @return Indi - */ - public function setUid($uid = '') - { - $this->uid = $uid; - return $this; - } - - /** - * @return string - */ - public function getUid() - { - return $this->uid; - } - - /** - * @param Indi\Name $name - * @return Indi - */ - public function addName($name = []) - { - $this->name[] = $name; - return $this; - } - - /** - * @return Indi\Name[] - */ - public function getName() - { - return $this->name; - } - - /** - * @param Indi\Attr $attr - * @return Indi - */ - public function addAttr($attr = []) - { - $attrName = $attr->getType(); - - if (!array_key_exists($attrName, $this->attr)) { - $this->attr[$attrName] = []; - } - - $this->attr[$attrName][] = $attr; - return $this; - } - - /** - * @return array - */ - public function getAllAttr() - { - return $this->attr; - } - - /** - * @return Indi\Attr[] - */ - public function getAttr($key = '') - { - if(isset($this->attr[strtoupper($key)])) - return $this->attr[strtoupper($key)]; - } - - /** - * @param Indi\Even $even - * @return Indi - */ - public function addEven($even = []) - { - $evenName = $even->getType(); - - if (!array_key_exists($evenName, $this->even)) { - $this->even[$evenName] = []; - } - - $this->even[$evenName][] = $even; - return $this; - } - - /** - * @return array - */ - public function getAllEven() - { - return $this->even; - } - - /** - * @return array - */ - public function getEven($key = '') - { - if(isset($this->even[strtoupper($key)])) - return $this->even[strtoupper($key)]; - } - - /** - * @param Indi\Asso $asso - * @return Indi - */ - public function addAsso($asso = []) - { - $this->asso[] = $asso; - return $this; - } - - /** - * @return array - */ - public function getAsso() - { - return $this->asso; - } - - /** - * @param Refn $ref - * @return Indi - */ - public function addRefn($ref = []) - { - $this->refn[] = $ref; - return $this; - } - - /** - * @return Refn[] - */ - public function getRefn() - { - return $this->refn; - } - - /** - * @param NoteRef $note - * @return Indi - */ - public function addNote($note = []) - { - $this->note[] = $note; - return $this; - } - - /** - * @return array - */ - public function getNote() - { - return $this->note; - } - - /** - * @param ObjeRef $obje - * @return Indi - */ - public function addObje($obje = []) - { - $this->obje[] = $obje; - return $this; - } - - /** - * @return array - */ - public function getObje() - { - return $this->obje; - } - - /** - * @param SourRef $sour - * @return Indi - */ - public function addSour($sour = []) - { - $this->sour[] = $sour; - return $this; - } - - /** - * @return array - */ - public function getSour() - { - return $this->sour; - } - - /** - * @param string $indi - * @return Indi - */ - public function addAlia($indi = '') - { - $this->alia[] = $indi; - return $this; - } - - /** - * @return array - */ - public function getAlia() - { - return $this->alia; - } - - /** - * @param Indi\Famc $famc - * @return Indi - */ - public function addFamc($famc = []) - { - $this->famc[] = $famc; - return $this; - } - - /** - * @return array - */ - public function getFamc() - { - return $this->famc; - } - - /** - * @param Indi\Fams $fams - * @return Indi - */ - public function addFams($fams = []) - { - $this->fams[] = $fams; - return $this; - } - - /** - * @return array - */ - public function getFams() - { - return $this->fams; - } - - /** - * @param string $subm - * @return Indi - */ - public function addAnci($subm = '') - { - $this->anci[] = $subm; - return $this; - } - - /** - * @return string[] - */ - public function getAnci() - { - return $this->anci; - } - - /** - * @param string $subm - * @return Indi - */ - public function addDesi($subm = '') - { - $this->desi[] = $subm; - return $this; - } - - /** - * @return string[] - */ - public function getDesi() - { - return $this->desi; - } - - /** - * @param string $subm - * @return Indi - */ - public function addSubm($subm = '') - { - $this->subm[] = $subm; - return $this; - } - - /** - * @return string[] - */ - public function getSubm() - { - return $this->subm; - } - - /** - * @param string $resn - * @return Indi - */ - public function setResn($resn = '') - { - $this->resn = $resn; - return $this; - } - - /** - * @return string - */ - public function getResn() - { - return $this->resn; - } - - /** - * @param string $sex - * @return Indi - */ - public function setSex($sex = '') - { - $this->sex = $sex; - return $this; - } - - /** - * @return string - */ - public function getSex() - { - return $this->sex; - } - - /** - * @param string $rfn - * @return Indi - */ - public function setRfn($rfn = '') - { - $this->rfn = $rfn; - return $this; - } - - /** - * @return string - */ - public function getRfn() - { - return $this->rfn; - } - - /** - * @param string $afn - * @return Indi - */ - public function setAfn($afn = '') - { - $this->afn = $afn; - return $this; - } - - /** - * @return string - */ - public function getAfn() - { - return $this->afn; - } - - /** - * @param string $chan - * @return Indi - */ - public function setChan($chan = '') - { - $this->chan = $chan; - return $this; - } - - /** - * @return string - */ - public function getChan() - { - return $this->chan; - } - - /** - * @param string $rin - * @return Indi - */ - public function setRin($rin = '') - { - $this->rin = $rin; - return $this; - } - - /** - * @return string - */ - public function getRin() - { - return $this->rin; - } - - /** - * @param Indi\Bapl $bapl - * @return Indi - */ - public function setBapl($bapl = []) - { - $this->bapl = $bapl; - return $this; - } - - /** - * @return Indi\Bapl - */ - public function getBapl() - { - return $this->bapl; - } - - /** - * @param Indi\Conl $conl - * @return Indi - */ - public function setConl($conl = []) - { - $this->conl = $conl; - return $this; - } - - /** - * @return Indi\Conl - */ - public function getConl() - { - return $this->conl; - } - - /** - * @param Indi\Endl $endl - * @return Indi - */ - public function setEndl($endl = []) - { - $this->endl = $endl; - return $this; - } - - /** - * @return Indi\Endl - */ - public function getEndl() - { - return $this->endl; - } - - /** - * @param Indi\Slgc $slgc - * @return Indi - */ - public function setSlgc($slgc = []) - { - $this->slgc = $slgc; - return $this; - } - - /** - * @return Indi\Slgc - */ - public function getSlgc() - { - return $this->slgc; - } +class Indi extends Record implements Noteable, Objectable, Sourceable { + /** + * @var string + */ + protected $id; + + /** + * @var string + */ + protected $uid; + + /** + * @var string + */ + protected $chan; + + /** + * @var Indi\Attr[] + */ + protected $attr = array(); + + /** + * @var Indi\Even[] + */ + protected $even = array(); + + /** + * @var Indi\Note[] + */ + protected $note = array(); + + /** + * @var Obje[] + */ + protected $obje = array(); + + /** + * @var Sour[] + */ + protected $sour = array(); + + /** + * @var Indi\Name[] + */ + protected $name = array(); + + /** + * @var string[] + */ + protected $alia = array(); + + /** + * @var string + */ + protected $sex; + + /** + * @var string + */ + protected $rin; + + /** + * @var string + */ + protected $resn; + + /** + * @var string + */ + protected $rfn; + + /** + * @var string + */ + protected $afn; + + /** + * @var Indi\Fams[] + */ + protected $fams = array(); + + /** + * @var Indi\Famc[] + */ + protected $famc = array(); + + /** + * @var Indi\Asso[] + */ + protected $asso = array(); + + /** + * @var string[] + */ + protected $subm = array(); + + /** + * @var string[] + */ + protected $anci = array(); + + /** + * @var string[] + */ + protected $desi = array(); + + /** + * @var Refn[] + */ + protected $refn = array(); + + /** + * @var Indi\Bapl + */ + protected $bapl; + + /** + * @var Indi\Conl + */ + protected $conl; + + /** + * @var Indi\Endl + */ + protected $endl; + + /** + * @var Indi\Slgc + */ + protected $slgc; + + /** + * @param string $id + * @return Indi + */ + public function setId($id = '') { + $this->id = $id; + return $this; + } + + /** + * @return string + */ + public function getId() { + return $this->id; + } + + /** + * @param string $uid + * @return Indi + */ + public function setUid($uid = '') { + $this->uid = $uid; + return $this; + } + + /** + * @return string + */ + public function getUid() { + return $this->uid; + } + + /** + * @param Indi\Name $name + * @return Indi + */ + public function addName($name = []) { + $this->name[] = $name; + return $this; + } + + /** + * @return Indi\Name[] + */ + public function getName() { + return $this->name; + } + + /** + * @param Indi\Attr $attr + * @return Indi + */ + public function addAttr($attr = []) { + $attrName = $attr->getType(); + + if (!array_key_exists($attrName, $this->attr)) { + $this->attr[$attrName] = []; + } + + $this->attr[$attrName][] = $attr; + return $this; + } + + /** + * @return Indi\Attr[] + */ + public function getAllAttr() { + return $this->attr; + } + /** + * @return Indi\Attr[] + */ + public function getAttr($key = '') { + if (isset($this->attr[strtoupper($key)])) { + return $this->attr[strtoupper($key)]; + } + + } + /** + * @param Indi\Even $even + * @return Indi + */ + public function addEven($even = []) { + $evenName = $even->getType(); + + if (!array_key_exists($evenName, $this->even)) { + $this->even[$evenName] = []; + } + + $this->even[$evenName][] = $even; + return $this; + } + + /** + * @return array + */ + public function getAllEven() { + return $this->even; + } + + /** + * @return array + */ + public function getEven($key = '') { + if (isset($this->even[strtoupper($key)])) { + return $this->even[strtoupper($key)]; + } + + } + + /** + * @param Indi\Asso $asso + * @return Indi + */ + public function addAsso($asso = []) { + $this->asso[] = $asso; + return $this; + } + + /** + * @return array + */ + public function getAsso() { + return $this->asso; + } + + /** + * @param Refn $ref + * @return Indi + */ + public function addRefn($ref = []) { + $this->refn[] = $ref; + return $this; + } + + /** + * @return Refn[] + */ + public function getRefn() { + return $this->refn; + } + + /** + * @param \PhpGedcom\Record\NoteRef $note + * @return Indi + */ + public function addNote($note = []) { + $this->note[] = $note; + return $this; + } + + /** + * @return array + */ + public function getNote() { + return $this->note; + } + + /** + * @param ObjeRef $obje + * @return Indi + */ + public function addObje($obje = []) { + $this->obje[] = $obje; + return $this; + } + + /** + * @return array + */ + public function getObje() { + return $this->obje; + } + + /** + * @param SourRef $sour + * @return Indi + */ + public function addSour($sour = []) { + $this->sour[] = $sour; + return $this; + } + + /** + * @return array + */ + public function getSour() { + return $this->sour; + } + + /** + * @param string $indi + * @return Indi + */ + public function addAlia($indi = '') { + $this->alia[] = $indi; + return $this; + } + + /** + * @return array + */ + public function getAlia() { + return $this->alia; + } + + /** + * @param Indi\Famc $famc + * @return Indi + */ + public function addFamc($famc = []) { + $this->famc[] = $famc; + return $this; + } + + /** + * @return array + */ + public function getFamc() { + return $this->famc; + } + + /** + * @param Indi\Fams $fams + * @return Indi + */ + public function addFams($fams = []) { + $this->fams[] = $fams; + return $this; + } + + /** + * @return array + */ + public function getFams() { + return $this->fams; + } + + /** + * @param string $subm + * @return Indi + */ + public function addAnci($subm = '') { + $this->anci[] = $subm; + return $this; + } + + /** + * @return string[] + */ + public function getAnci() { + return $this->anci; + } + + /** + * @param string $subm + * @return Indi + */ + public function addDesi($subm = '') { + $this->desi[] = $subm; + return $this; + } + + /** + * @return string[] + */ + public function getDesi() { + return $this->desi; + } + + /** + * @param string $subm + * @return Indi + */ + public function addSubm($subm = '') { + $this->subm[] = $subm; + return $this; + } + + /** + * @return string[] + */ + public function getSubm() { + return $this->subm; + } + + /** + * @param string $resn + * @return Indi + */ + public function setResn($resn = '') { + $this->resn = $resn; + return $this; + } + + /** + * @return string + */ + public function getResn() { + return $this->resn; + } + + /** + * @param string $sex + * @return Indi + */ + public function setSex($sex = '') { + $this->sex = $sex; + return $this; + } + + /** + * @return string + */ + public function getSex() { + return $this->sex; + } + + /** + * @param string $rfn + * @return Indi + */ + public function setRfn($rfn = '') { + $this->rfn = $rfn; + return $this; + } + + /** + * @return string + */ + public function getRfn() { + return $this->rfn; + } + + /** + * @param string $afn + * @return Indi + */ + public function setAfn($afn = '') { + $this->afn = $afn; + return $this; + } + + /** + * @return string + */ + public function getAfn() { + return $this->afn; + } + + /** + * @param string $chan + * @return Indi + */ + public function setChan($chan = '') { + $this->chan = $chan; + return $this; + } + + /** + * @return string + */ + public function getChan() { + return $this->chan; + } + + /** + * @param string $rin + * @return Indi + */ + public function setRin($rin = '') { + $this->rin = $rin; + return $this; + } + + /** + * @return string + */ + public function getRin() { + return $this->rin; + } + + /** + * @param Indi\Bapl $bapl + * @return Indi + */ + public function setBapl($bapl = []) { + $this->bapl = $bapl; + return $this; + } + + /** + * @return Indi\Bapl + */ + public function getBapl() { + return $this->bapl; + } + + /** + * @param Indi\Conl $conl + * @return Indi + */ + public function setConl($conl = []) { + $this->conl = $conl; + return $this; + } + + /** + * @return Indi\Conl + */ + public function getConl() { + return $this->conl; + } + + /** + * @param Indi\Endl $endl + * @return Indi + */ + public function setEndl($endl = []) { + $this->endl = $endl; + return $this; + } + + /** + * @return Indi\Endl + */ + public function getEndl() { + return $this->endl; + } + + /** + * @param Indi\Slgc $slgc + * @return Indi + */ + public function setSlgc($slgc = []) { + $this->slgc = $slgc; + return $this; + } + + /** + * @return Indi\Slgc + */ + public function getSlgc() { + return $this->slgc; + } } diff --git a/library/PhpGedcom/Record/Indi/Name.php b/library/PhpGedcom/Record/Indi/Name.php index 47508b24..4cd3756b 100644 --- a/library/PhpGedcom/Record/Indi/Name.php +++ b/library/PhpGedcom/Record/Indi/Name.php @@ -15,41 +15,44 @@ namespace PhpGedcom\Record\Indi; /** - * + * @method string getName() + * @method string getNpfx() + * @method string getGivn() + * @method string getNick() + * @method string getSpfx() + * @method string getSurn() + * @method string getNsfx() */ -class Name extends \PhpGedcom\Record implements \PhpGedcom\Record\Sourceable -{ - protected $_name = null; - protected $_npfx = null; - protected $_givn = null; - protected $_nick = null; - protected $_spfx = null; - protected $_surn = null; - protected $_nsfx = null; +class Name extends \PhpGedcom\Record implements \PhpGedcom\Record\Sourceable { + protected $_name = null; + protected $_npfx = null; + protected $_givn = null; + protected $_nick = null; + protected $_spfx = null; + protected $_surn = null; + protected $_nsfx = null; - /** - * - */ - protected $_note = array(); + /** + * + */ + protected $_note = array(); - /** - * - */ - protected $_sour = array(); + /** + * + */ + protected $_sour = array(); - /** - * - */ - public function addSour($sour = []) - { - $this->_sour[] = $sour; - } + /** + * + */ + public function addSour($sour = []) { + $this->_sour[] = $sour; + } - /** - * - */ - public function addNote($note = []) - { - $this->_note[] = $note; - } + /** + * + */ + public function addNote($note = []) { + $this->_note[] = $note; + } } diff --git a/library/PhpGedcom/Record/Repo.php b/library/PhpGedcom/Record/Repo.php index 8cd5fa08..0e3e0de6 100644 --- a/library/PhpGedcom/Record/Repo.php +++ b/library/PhpGedcom/Record/Repo.php @@ -20,189 +20,184 @@ * Class Repo * @package PhpGedcom\Record */ -class Repo extends Record implements Noteable -{ - /** - * @var string - */ - protected $repo; - - /** - * @var string - */ - protected $name; - - /** - * @var Addr - */ - protected $addr; - - /** - * @var string - */ - protected $rin; - - /** - * @var Chan - */ - protected $chan; - - /** - * @var array - */ - protected $phon = array(); - - /** - * @var array - */ - protected $refn = array(); - - /** - * @var array - */ - protected $note = array(); - - /** - * @param Phon $phon - * @return Repo - */ - public function addPhon($phon = new Phon) - { - $this->phon[] = $phon; - return $this; - } - - /** - * @return array - */ - public function getPhon() - { - return $this->phon; - } - - /** - * @param Refn $refn - * @return Repo - */ - public function addRefn($refn = new Refn) - { - $this->refn[] = $refn; - return $this; - } - - /** - * @return array - */ - public function getRefn() - { - return $this->refn; - } - - /** - * @param NoteRef $note - * @return Repo - */ - public function addNote($note = new NoteRef) - { - $this->note[] = $note; - return $this; - } - - /** - * @return array - */ - public function getNote() - { - return $this->note; - } - - /** - * @param string $repo - * @return Repo - */ - public function setRepo($repo = '') - { - $this->repo = $repo; - return $this; - } - - /** - * @return string - */ - public function getRepo() - { - return $this->repo; - } - - /** - * @param string $name - * @return Repo - */ - public function setName($name = '') - { - $this->name = $name; - return $this; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param \PhpGedcom\Record\Addr $addr - * @return Repo - */ - public function setAddr($addr = new Addr) - { - $this->addr = $addr; - return $this; - } - - /** - * @return \PhpGedcom\Record\Addr - */ - public function getAddr() - { - return $this->addr; - } - - /** - * @param string $rin - * @return Repo - */ - public function setRin($rin = '') - { - $this->rin = $rin; - return $this; - } - - /** - * @return string - */ - public function getRin() - { - return $this->rin; - } - - /** - * @param \PhpGedcom\Record\Chan $chan - * @return Repo - */ - public function setChan($chan = []) - { - $this->chan = $chan; - return $this; - } - - /** - * @return \PhpGedcom\Record\Chan - */ - public function getChan() - { - return $this->chan; - } +class Repo extends Record implements Noteable { + /** + * @var string + */ + protected $repo; + + /** + * @var string + */ + protected $name; + + /** + * @var Addr + */ + protected $addr; + + /** + * @var string + */ + protected $rin; + + /** + * @var Chan + */ + protected $chan; + + /** + * @var array + */ + protected $phon = array(); + + /** + * @var array + */ + protected $refn = array(); + + /** + * @var array + */ + protected $note = array(); + + /** + * @param null|\PhpGedcom\Record\Phon $phons + * @return Repo + */ + public function addPhon($phon = null) { + if (empty($phon)) { + $phon = new \PhpGedcom\Record\Phon(); + } + $this->phon[] = $phon; + return $this; + } + + /** + * @return array + */ + public function getPhon() { + return $this->phon; + } + + /** + * @param null|\PhpGedcom\Record\Refn $refn + * @return Repo + */ + public function addRefn($refn = null) { + if (empty($refn)) { + $refn = new \PhpGedcom\Record\Refn(); + } + $this->refn[] = $refn; + return $this; + } + + /** + * @return array + */ + public function getRefn() { + return $this->refn; + } + + /** + * @param null|\PhpGedcom\Record\NoteRef $note + * @return Repo + */ + public function addNote($note = null) { + if (empty($node)) { + $note = new \PhpGedcom\Record\NoteRef(); + } + $this->note[] = $note; + return $this; + } + + /** + * @return array + */ + public function getNote() { + return $this->note; + } + + /** + * @param string $repo + * @return Repo + */ + public function setRepo($repo = '') { + $this->repo = $repo; + return $this; + } + + /** + * @return string + */ + public function getRepo() { + return $this->repo; + } + + /** + * @param string $name + * @return Repo + */ + public function setName($name = '') { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() { + return $this->name; + } + + /** + * @param null|\PhpGedcom\Record\Addr $addr + * @return Repo + */ + public function setAddr($addr = null) { + if (empty($addr)) { + $addr = new \PhpGedcom\Record\Addr(); + } + $this->addr = $addr; + return $this; + } + + /** + * @return \PhpGedcom\Record\Addr + */ + public function getAddr() { + return $this->addr; + } + + /** + * @param string $rin + * @return Repo + */ + public function setRin($rin = '') { + $this->rin = $rin; + return $this; + } + + /** + * @return string + */ + public function getRin() { + return $this->rin; + } + + /** + * @param \PhpGedcom\Record\Chan $chan + * @return Repo + */ + public function setChan($chan = []) { + $this->chan = $chan; + return $this; + } + + /** + * @return \PhpGedcom\Record\Chan + */ + public function getChan() { + return $this->chan; + } } diff --git a/library/PhpGedcom/Record/Subm.php b/library/PhpGedcom/Record/Subm.php index e71c447e..21eff443 100644 --- a/library/PhpGedcom/Record/Subm.php +++ b/library/PhpGedcom/Record/Subm.php @@ -20,222 +20,223 @@ * Class Subm * @package PhpGedcom\Record */ -class Subm extends Record implements Objectable -{ - /** - * @var string - */ - protected $subm; - - /** - * @var Record\Chan - */ - protected $chan; - - /** - * @var string - */ - protected $name; - - /** - * @var Record\Addr - */ - protected $addr; - - /** - * @var string - */ - protected $rin; - - /** - * @var string - */ - protected $rfn; - - /** - * @var array - */ - protected $lang = array(); - - /** - * @var array - */ - protected $phon = array(); - - /** - * @var array - */ - protected $obje = array(); - - /** - * @param string $subm - * @return Subm - */ - public function setSubm($subm = '') - { - $this->subm = $subm; - return $this; - } - - /** - * @return string - */ - public function getSubm() - { - return $this->subm; - } - - /** - * @param string $name - * @return Subm - */ - public function setName($name = '') - { - $this->name = $name; - return $this; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param array $phon - * @return Subm - */ - public function setPhon($phon = []) - { - $this->phon = $phon; - return $this; - } - - /** - * @return array - */ - public function getPhon() - { - return $this->phon; - } - - /** - * @param string $rfn - * @return Subm - */ - public function setRfn($rfn = '') - { - $this->rfn = $rfn; - return $this; - } - - /** - * @return string - */ - public function getRfn() - { - return $this->rfn; - } - - /** - * @param string $rin - * @return Subm - */ - public function setRin($rin = '') - { - $this->rin = $rin; - return $this; - } - - /** - * @return string - */ - public function getRin() - { - return $this->rin; - } - - /** - * @param \PhpGedcom\Record\Chan $chan - * @return Subm - */ - public function setChan($chan = []) - { - $this->chan = $chan; - return $this; - } - - /** - * @return \PhpGedcom\Record\Chan - */ - public function getChan() - { - return $this->chan; - } - - /** - * @return array - */ - public function getLang() - { - return $this->lang; - } - - /** - * @param string $lang - * @return Subm - */ - public function addLang($lang = '') - { - $this->lang[] = $lang; - return $this; - } - - /** - * @param Record\Phon $phon - * @return Subm - */ - public function addPhon($phon = []) - { - $this->phon[] = $phon; - return $this; - } - - /** - * @return Addr - */ - public function getAddr() - { - return $this->addr; - } - - /** - * @param Addr $addr - * @return Subm - */ - public function setAddr($addr = []) - { - $this->addr = $addr; - return $this; - } - - /** - * @return array - */ - public function getObje() - { - return $this->obje; - } - - /** - * @param Record\ObjeRef $obje - * @return Subm - */ - public function addObje($obje = []) - { - $this->obje[] = $obje; - return $this; - } +class Subm extends Record implements Objectable { + /** + * @var string + */ + protected $subm; + + /** + * @var Record\Chan + */ + protected $chan; + + /** + * @var string + */ + protected $name; + + /** + * @var Record\Addr + */ + protected $addr; + + /** + * @var string + */ + protected $rin; + + /** + * @var string + */ + protected $rfn; + + /** + * @var array + */ + protected $lang = array(); + + /** + * @var array + */ + protected $phon = array(); + + /** + * @var array + */ + protected $obje = array(); + + /** + * @var array + */ + protected $note = array(); + + /** + * @param string $subm + * @return Subm + */ + public function setSubm($subm = '') { + $this->subm = $subm; + return $this; + } + + /** + * @return string + */ + public function getSubm() { + return $this->subm; + } + + /** + * @param string $name + * @return Subm + */ + public function setName($name = '') { + $this->name = $name; + return $this; + } + + /** + * @return string + */ + public function getName() { + return $this->name; + } + + /** + * @param array $phon + * @return Subm + */ + public function setPhon($phon = []) { + $this->phon = $phon; + return $this; + } + + /** + * @return array + */ + public function getPhon() { + return $this->phon; + } + + /** + * @param string $rfn + * @return Subm + */ + public function setRfn($rfn = '') { + $this->rfn = $rfn; + return $this; + } + + /** + * @return string + */ + public function getRfn() { + return $this->rfn; + } + + /** + * @param string $rin + * @return Subm + */ + public function setRin($rin = '') { + $this->rin = $rin; + return $this; + } + + /** + * @return string + */ + public function getRin() { + return $this->rin; + } + + /** + * @param \PhpGedcom\Record\Chan $chan + * @return Subm + */ + public function setChan($chan = []) { + $this->chan = $chan; + return $this; + } + + /** + * @return \PhpGedcom\Record\Chan + */ + public function getChan() { + return $this->chan; + } + + /** + * @return array + */ + public function getLang() { + return $this->lang; + } + + /** + * @param string $lang + * @return Subm + */ + public function addLang($lang = '') { + $this->lang[] = $lang; + return $this; + } + + /** + * @param Record\Phon $phon + * @return Subm + */ + public function addPhon($phon = []) { + $this->phon[] = $phon; + return $this; + } + + /** + * @return Addr + */ + public function getAddr() { + return $this->addr; + } + + /** + * @param Addr $addr + * @return Subm + */ + public function setAddr($addr = []) { + $this->addr = $addr; + return $this; + } + + /** + * @return array + */ + public function getObje() { + return $this->obje; + } + + /** + * @param Record\ObjeRef $obje + * @return Subm + */ + public function addObje($obje = []) { + $this->obje[] = $obje; + return $this; + } + + /** + * @return array + */ + public function getNote() { + return $this->note; + } + + /** + * @param Record\Note $note + * @return Subm + */ + public function addNote($note = []) { + $this->note[] = $note; + return $this; + } }