interface iTuple extends BaseIface {
// ACCESS
function Name() : string;
function AddExtra(string $s);
// ++ DIAGNOSTICS ++ // - to be moved to Viewer() (...except why bother?)
function DumpLine() : string;
function DumpLines() : string;
// -- DIAGNOSTICS -- //
}
class cTuple extends BaseClass implements iTuple {
public function __construct(protected string $sName, string $sValue=NULL) {
$this->SetItNz($sValue);
}
// ++ ACCESS ++ //
public function Name() : string { return $this->sName; }
// ALIAS
public function Value() : string { return $this->GetIt(); }
// If no explicit value, key is default value:
public function ValueNz() : string { return $this->GetItNz($this->Name()); }
private $arXt=[];
public function AddExtra(string $s) { $this->arXt[] = $s; }
public function GetExtras() : array { return $this->arXt; }
// -- ACCESS -- //
// ++ DIAGNOSTICS ++ //
public function DumpLine() : string {
$oScrn = self::Screen();
$sName = $this->Name();
$sValue = $this->Value(); // TODO: allow for NULL value
$ftName = $oScrn->BoldIt($sName);
$ftValue = $oScrn->BoldIt($sValue);
return "[$ftName]:[$ftValue]";
}
public function DumpLines() : string {
$oScrn = self::Screen();
$sName = $this->Name();
$sValue = $this->Value();
$ftName = $oScrn->BoldIt('Name').": [$sName]";
$ftValue = $oScrn->BoldIt('Value').": [$sValue]";
$oList = $oScrn->NewList();
$oList->AddLine($ftName);
$oList->AddLine($ftValue);
return $oList->Render();
}
// -- DIAGNOSTICS -- //
}