Ferreteria/v0.6/clade/Sys/Data/Things/Array/View

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | Things‎ | Array
Revision as of 14:33, 12 November 2025 by Woozle (talk | contribs) (Created page with "{{page/clade/v2 |fam= {{!}} align=right {{!}} {{l/ver/clade|IO\O\View|Debug}} {{!}} align=center {{!}} ⇒ {{l/ver/clade|Sys\Data\Things\Array|View}} ⇒ {{!}} align=left {{!}} {{l/ver/clade|Sys\Data\Things\Array\View|Grid}}<br> {{l/ver/clade|Sys\Data\Things\Array\View|List}}<br> {{l/ver/clade|Sys\Data\Things\Array\View|Multi}}<br> {{l/ver/clade|Sys\Data\Things\Array\View|Row}} |alia= {{!-!}} '''ArrayIface''' {{!!}} {{l/ver/clade/full|p=ferreteria|Sys\Data\T...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
clade: Sys\Data\Things\Array\View
Clade Family
Debug View

Grid
List
Multi
Row

Clade Aliases
Alias Clade
ArrayIface Sys\Data\Things\Array
Base* [c,i] IO\O\View\Debug
Subpages

History

  • 2025-10-28 created: experiment to make the Inspect API more usable

Code

as of 2025-11-12

interface iView extends BaseIface {
    static function FromOArray(ArrayIface $oa) : self;
}
class cView extends BaseClass implements iView {

    // ++ SETUP ++ //

    public function __construct(ArrayIface $oa) { $this->WithOArray($oa); }

    public static function FromOArray(ArrayIface $oa) : iView {
        $oThis = new static;
        $oThis->WithOArray($oa);
        return $oThis;
    }

    // ++ SETUP: dynamic ++ //

    private $oa;
    protected function WithOArray(ArrayIface $oa) : void { $this->oa = $oa; }
    protected function OArray() : ArrayIface { return $this->oa; }

    // -- SETUP -- //
    // ++ OUTPUT ++ //

    public function Render() : string {
        $ar = $this->OArray()->GetVals();
        $n = count($ar);
        $sS = ($n === 1) ? '' : 's';
        $sOut = "array has $n element$sS:".CRLF;
        foreach ($ar as $snKey => $vVal) {
            $sElem = self::DiagnoseValue($vVal);
            $sOut .= "[$snKey] => $sElem".CRLF;
        }
        return $sOut;
    }

    // -- OUTPUT -- //

}