Add isXXX getter to Entity

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2019-10-22 14:54:21 +02:00
parent ac1585b316
commit ce9a434fb2
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with 12 additions and 9 deletions

View File

@ -24,6 +24,9 @@
namespace OCP\AppFramework\Db;
use function lcfirst;
use function substr;
/**
* @method integer getId()
* @method void setId(integer $id)
@ -139,16 +142,16 @@ abstract class Entity {
* getter method
* @since 7.0.0
*/
public function __call($methodName, $args){
$attr = lcfirst( substr($methodName, 3) );
if(strpos($methodName, 'set') === 0){
$this->setter($attr, $args);
} elseif(strpos($methodName, 'get') === 0) {
return $this->getter($attr);
public function __call($methodName, $args) {
if (strpos($methodName, 'set') === 0) {
$this->setter(lcfirst(substr($methodName, 3)), $args);
} elseif (strpos($methodName, 'get') === 0) {
return $this->getter(lcfirst(substr($methodName, 3)));
} elseif (strpos($methodName, 'is') === 0) {
return $this->getter(lcfirst(substr($methodName, 2)));
} else {
throw new \BadFunctionCallException($methodName .
' does not exist');
throw new \BadFunctionCallException($methodName .
' does not exist');
}
}