Rename PropertiesBase to more accurate Accessor

This commit is contained in:
Alex Cabal 2024-02-24 13:58:24 -06:00
parent 06fce2f089
commit 350f65532f
13 changed files with 13 additions and 13 deletions

View file

@ -1,50 +0,0 @@
<?
abstract class PropertiesBase{
/**
* @return mixed
*/
public function __get(string $var){
$function = 'Get' . $var;
$privateVar = '_' . $var;
if(method_exists($this, $function)){
return $this->$function();
}
elseif(property_exists($this, $var . 'Id') && property_exists($this, $privateVar) && method_exists($var, 'Get')){
// If we're asking for a private `_Var` property,
// and we have a public `VarId` property,
// and the `Var` class also has a `Var::Get` method,
// call that method and return the result.
if($this->$privateVar === null && $this->{$var . 'Id'} !== null){
$this->$privateVar = $var::Get($this->{$var . 'Id'});
}
return $this->$privateVar;
}
elseif(property_exists($this, $privateVar)){
return $this->{$privateVar};
}
else{
return $this->$var;
}
}
/**
* @param mixed $val
* @return mixed
*/
public function __set(string $var, $val){
$function = 'Set' . $var;
$privateVar = '_' . $var;
if(method_exists($this, $function)){
$this->$function($val);
}
elseif(property_exists($this, $privateVar)){
$this->$privateVar = $val;
}
else{
$this->$var = $val;
}
}
}