class cNode extends BaseClass implements iNode {
use RowViewTrait;
// ++ CONFIG ++ //
protected function InspectorClass() : string { return RowViewClass::class; }
static protected function FiNodeClass() : string { return FiNodeClass::class; }
static protected function FoNodeClass() : string { return FoNodeClass::class; }
protected function IdentClass() : string { return IdentClass::class; }
protected function InOutClass() : string { return InOutClass::class; }
// -- CONFIG -- //
// ++ SETUP ++ //
protected function __construct(){} // only construct via static pseudoconstructors
// IFACE
static public function FromRowData(RowDataIface $oa) : RowViewIface {
$oThis = new static;
$oThis->WithRowData($oa);
return $oThis;
}
static public function FromSpec(string $fs) : iNode {
if (file_exists($fs)) {
if (is_file($fs)) {
$sc = static::FiNodeClass();
} elseif (is_dir($fs)) {
$sc = static::FoNodeClass();
} else {
echo self::CodingPrompt("Node type for [$fs] needs to be handled."); die();
}
} else {
// Node not found; assume folder if there's an ending slash
$isFldr = str_ends_with($fs,self::Settings()::FILE_PATH_SEP);
if ($isFldr) {
$sc = static::FoNodeClass();
} else {
$sc = static::FiNodeClass();
}
}
$oThis = new $sc;
$oThis->WithSpec($fs);
return $oThis;
}
static public function FromSplInfo(SplFileInfo $on) : iNode {
$oThis = new static;
$oThis->Ident()->QSFullSpec()->SetIt($on->getPathname());
return $oThis;
}
// ++ SETUP: dynamic ++ //
protected function WithSpec(string $fs) : void {
$this->Ident()->QSFullSpec()->SetIt($fs);
}
protected function WithRowData(RowDataIface $oa) : void {
self::PromptForMethod();
}
// -- SETUP -- //
// ++ ASPECTS ++ //
private $oID = NULL;
public function Ident(?IdentIface $o=NULL) : IdentIface { return is_object($o) ? ($this->oID = $o) : ($this->oID ?? ($this->oID = $this->NewIdent())); }
protected function NewIdent() : IdentIface { return ($this->IdentClass())::FromNode($this); }
private $oIO = NULL;
public function InOut(?InOutIface $o=NULL) : InOutIface { return is_object($o) ? ($this->oIO = $o) : ($this->oIO ?? ($this->oIO = $this->NewInOut())); }
protected function NewInOut() : InOutIface { return ($this->InOutClass())::FromNode($this); }
// -- ASPECTS -- //
}