-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
055ef8c
commit 87f95ed
Showing
4 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Gedcom\Parser\Head; | ||
|
||
class Dest extends \Gedcom\Parser\Component | ||
{ | ||
public static function parse(\Gedcom\Parser $parser) | ||
{ | ||
$record = $parser->getCurrentLineRecord(); | ||
$depth = (int) $record[0]; | ||
$dest = new \Gedcom\Record\Head\Dest(); | ||
$dest->setDest(trim((string) $record[2])); | ||
|
||
$parser->forward(); | ||
|
||
while (!$parser->eof()) { | ||
$record = $parser->getCurrentLineRecord(); | ||
$currentDepth = (int) $record[0]; | ||
$recordType = strtoupper(trim((string) $record[1])); | ||
|
||
if ($currentDepth <= $depth) { | ||
$parser->back(); | ||
break; | ||
} | ||
|
||
switch ($recordType) { | ||
// Add cases for DEST sub-tags here if needed | ||
default: | ||
$parser->logUnhandledRecord(self::class.' @ '.__LINE__); | ||
} | ||
|
||
$parser->forward(); | ||
} | ||
|
||
return $dest; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Gedcom\Record\Head; | ||
|
||
class Dest extends \Gedcom\Record | ||
{ | ||
protected $_dest; | ||
|
||
public function setDest($dest) | ||
{ | ||
$this->_dest = $dest; | ||
} | ||
|
||
public function getDest() | ||
{ | ||
return $this->_dest; | ||
} | ||
|
||
// Add more properties and methods for sub-tags if needed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Gedcom\Writer\Head; | ||
|
||
class Dest | ||
{ | ||
public static function convert(\Gedcom\Record\Head\Dest $dest, $level) | ||
{ | ||
$output = ''; | ||
$_dest = $dest->getDest(); | ||
if ($_dest) { | ||
$output .= $level.' DEST '.$_dest."\n"; | ||
} | ||
|
||
// Add conversion for sub-tags if needed | ||
|
||
return $output; | ||
} | ||
} |