Ferreteria/v0.6/clade/Data/Mem/QVar/Str: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{page/clade/v2 | {{page/clade/v2 | ||
|fam= | |fam= | ||
{{!}} align=right {{!}} {{l/ver/clade|Data\Mem|QVar}} | {{!}} align=right {{!}} <code>{{l/ver/clade|Data\Mem|QVar}}</code> | ||
{{!}} align=center {{!}} & | {{!}} align=center {{!}} ⇒ <code>{{l/ver/clade|Data\Mem\QVar|Str}}</code> ⇒ | ||
{{!}} align=left {{!}} | {{!}} align=left {{!}} | ||
<code>{{l/ver/clade|Data\Mem\QVar\Obj|Strict}}</code><br> | |||
<code>{{l/ver/clade|Sys\Data\Things\Array\aux|Tuple}}</code> | |||
|alia= | |alia= | ||
{{! | {{!-!}} '''Base'''* [ca,i] {{!!}} <code>{{l/ver/clade/full|Data\Mem|QVar}}</code> | ||
{{!-!}} '''TypesStatic''' [cs] {{!!}} <code>{{l/ver/clade/full|Data\Mem\Val|Types}}</code> | |||
{{! | |||
}} | }} | ||
| Line 19: | Line 19: | ||
}} | }} | ||
==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 | * '''{{fmt/date|2024|12|03}}''' Finally changed my mind (again) and decided it's ok to have sensible defaults in the constructor. | ||
** No need for <code>With*()</code> methods because they'd just be <code>{{l/ver/fx|SetIt}}()</code> / <code>{{l/ver/fx|SetItNz}}()</code>. | ** Just don't let it get too complicated by trying to accommodate too many possible cases; that's what <code>{{l/ver/fx|From*}}()</code> pseudoconstructors are for. | ||
** No need for <code>{{l/ver/fx|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}} | ||
* ''as of {{fmt/date|2025|10|17}}:'' | |||
''as of 2025 | |||
{{fmt/php/block|1= | {{fmt/php/block|1= | ||
interface iStr extends BaseIface { | interface iStr extends BaseIface { | ||
Latest revision as of 15:19, 21 November 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.
Code
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 -- //
}