Skip to content

Commit

Permalink
Updated 4 files
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Jul 19, 2024
1 parent 055ef8c commit 87f95ed
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Parser/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public static function parse(\Gedcom\Parser $parser)
$head->setSubn($parser->normalizeIdentifier($record[2]));
break;
case 'DEST':
$head->setDest(trim((string) $record[2]));
$dest = \Gedcom\Parser\Head\Dest::parse($parser);
$head->setDest($dest);
break;
case 'FILE':
$head->setFile(trim((string) $record[2]));
Expand Down
37 changes: 37 additions & 0 deletions src/Parser/Head/Dest.php
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;
}
}
20 changes: 20 additions & 0 deletions src/Record/Head/Dest.php
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
}
19 changes: 19 additions & 0 deletions src/Writer/Head/Dest.php
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;
}
}

0 comments on commit 87f95ed

Please sign in to comment.