Ferreteria/v0.6/clade/Data/Mem/QVar/Str: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{page/clade/v2 |fam= {{!}} align=right {{!}} {{l/ver/clade|Data\Mem|QVar}} {{!}} align=center {{!}} → {{l/ver/clade|Data\Mem\QVar|Str}} → {{!}} align=left {{!}} {{l/ver/clade|Data\Mem\QVar\Obj|Strict}} |alia= {{!}}- {{!}} '''Base'''* [ca,i] {{!!}} {{l/ver/clade/full|p=ferreteria|Data\Mem|QVar}} {{!}}- {{!}} '''TypesStatic''' [cs] {{!!}} {{l/ver/clade/full|p=ferreteria|Data\Mem\Val|Types}} }} ==Usage== Ferreteria standard aliasing: {{fmt/php/block| use Wooza...") |
|||
| Line 20: | Line 20: | ||
==History== | ==History== | ||
* '''{{fmt/date|2024|12|03}}''' Finally changed my mind (again) and decided it's ok to have sensible defaults in the constructor. Just don't let it get too complicated, by trying to accommodate too many possible cases; that's what <code>From*()</code> pseudoconstructors are for. | * '''{{fmt/date|2024|12|03}}''' Finally changed my mind (again) and decided it's ok to have sensible defaults in the constructor. Just don't let it get too complicated, by trying to accommodate too many possible cases; that's what <code>From*()</code> pseudoconstructors are for. | ||
** No need for <code>With*()</code> methods because they'd just be <code>{{l/ver/fx|SetIt}}()</code> / < | ** No need for <code>With*()</code> methods because they'd just be <code>{{l/ver/fx|SetIt}}()</code> / <code>{{l/ver/fx|SetItNz}}()</code>. | ||
==Code== | ==Code== | ||
* {{l/sub|@removed}} | * {{l/sub|@removed}} | ||
Revision as of 14:18, 17 October 2025
| ||||||||||||||||
Usage
Ferreteria standard aliasing:
use Woozalia\Ferret\Data\Mem\QVar\cStr as QStrClass;
use Woozalia\Ferret\Data\Mem\QVar\iStr as QStrIface;
History
- 2024-12-03 Finally changed my mind (again) and decided it's ok to have sensible defaults in the constructor. Just don't let it get too complicated, by trying to accommodate too many possible cases; that's what
From*()pseudoconstructors are for.
Code
as of 2025-10-17
interface iStr extends BaseIface {
// SETUP
static function FromString(string $s) : self;
static function FromNzString(?string $s = NULL) : self;
// ACCESS
function SetIt(string $s);
function SetItNz(?string $v);
function &GetIt() : string;
function GetItNz(string $sDefault='') : string;
function RefIt(string &$v) : void;
function CopyIt(BaseIface $os);
}
class cStr extends BaseClass implements iStr {
// ++ SETUP ++ //
public function __construct(string $s = NULL) { $this->SetItNz($s); }
static public function FromString(string $s) : iStr {
$oThis = new static;
$oThis->SetIt($s);
return $oThis;
}
static public function FromNzString(?string $s = NULL) : iStr {
return is_null($s) ? static::AsNew() : static::FromString($s);
}
public function CopyIt(BaseIface $os) { if ($os->HasIt()) $this->SetIt((string)$os->GetIt()); }
// -- SETUP -- //
// ++ ACCESS ++ //
public function HasIt() : bool { return $this->HasStr(); }
public function SetIt(string $s) { $this->SetStr($s); }
public function SetItNz(?string $s) { $this->SetStrNz($s); }
public function &GetIt() : string { return $this->GetStr(); }
public function GetItNz(string $sDef='',string $sPfx='',string $sSfx='') : string { return ($this->GetStrNz($sDef,$sPfx,$sSfx)); }
public function RefIt(string &$s) : void { $this->RefStr($s); }
// ++ ACCESS: internal ++ //
protected function TypeOk(mixed $v) : bool { return is_string($v); }
// -- ACCESS -- //
}