Ferreteria/v0.6/clade/Sys/Data/Things/Array/View
Jump to navigation
Jump to search
| ||||||||||||||||
History
Code
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 -- //
}