DbObject: provide methods checking for getters...

...and setters
This commit is contained in:
Thomas Gelf 2019-09-19 23:27:06 +02:00
parent 2cfd072739
commit 10be27c9a3
1 changed files with 18 additions and 4 deletions

View File

@ -268,14 +268,28 @@ abstract class DbObject
// There is getId, would give false positive
return false;
}
return $this->hasGetterForProperty($key);
}
protected function hasGetterForProperty($key)
{
$func = 'get' . ucfirst($key);
if (substr($func, -2) === '[]') {
if (\substr($func, -2) === '[]') {
$func = substr($func, 0, -2);
}
if (method_exists($this, $func)) {
return true;
return \method_exists($this, $func);
}
protected function hasSetterForProperty($key)
{
$func = 'set' . ucfirst($key);
if (\substr($func, -2) === '[]') {
$func = substr($func, 0, -2);
}
return false;
return \method_exists($this, $func);
}
/**