Futilities/v0.6/clade/Apps/dba/InArgs/@current

From WoozleCodes
Jump to navigation Jump to search
Code Snapshots
trait tInArgs { // for users of this format
    // ++ CONFIG ++ //

    // UNPROMPT for dba command (do not override in podlings)
    static protected final function InputClass() : string { return cInArgs::class; }

    // -- CONFIG -- //
}
interface iInArgs extends BaseIface {
    // DATA
    function OkToReplace() : bool;
}
class cInArgs extends BaseClass implements iInArgs {
    #use SchemerTrait;

    // ++ DATA ++ //

    public function QSDbase()     : QStrIface { return $this->FetchItQ(KioskIface::VAL_CONN);  }
    public function QSSchema()    : QStrIface { return $this->FetchItQ(KioskIface::VAL_SCHEMA); }
    public function QSFileName()  : QStrIface { return $this->FetchItQ(KioskIface::VAL_FILE); }
    public function QSFilePath()  : QStrIface { return $this->FetchItQ(KioskIface::VAL_PATH); }

    public function OkToReplace() : bool {
        #$sName = 'xf.replace';
        $sName = KioskEnum::VAL_REPLACE->value;
        $obVal = $this->FetchItQ($sName);
        $bVal = $obVal->HasIt() ? $obVal->GetIt() : FALSE;
        return $bVal;
    }

    // -- DATA -- //
    // ++ OBJECTS ++ //

    // 2025-11-21 Copied from has\Schema (for now)
    public function QOSchema() : QObjIface {
        $qo = QObjClass::AsNew();
        $os = $this->QSSchema();    // Schema name
        if ($os->HasIt()) {
            $sSch = $os->GetIt();
            $qoOper = $this->QOClient();  // creates new object if needed/possible
            if ($qoOper->HasIt()) {
                $oOper = $qoOper->GetIt();
                $oSch = $oOper->GetSchema($sSch);
                $qo->SetIt($oSch);
            }
        }
        return $qo;
    }

    // ++ OUTPUT ++ //

    // OVERRIDE
    public function Debug_Render() : string {
        $ar = $this->GetVals();
        $nAr = count($ar);
        if ($nAr > 0) {
            if ($nAr > 1) {
                $sOut = $nAr.' input elements:'.CRLF;
            } else {
                $sOut = 'One input element: ';
            }
            foreach ($ar as $sKey => $sVal) {
                $sOut .= "[$sKey] => [$sVal]".CRLF;
            }
        } else {
            $sOut = 'No elements in input array.'.CRLF;
        }

        return $sOut;

    }

    // -- OUTPUT -- //
}