Skip to content
Snippets Groups Projects
Unverified Commit 7960a71f authored by Roeland Jago Douma's avatar Roeland Jago Douma Committed by GitHub
Browse files

Merge pull request #17639 from nextcloud/enhancement/entity-boolean-getter

Add isXXX getter to Entity
parents 6be518c6 ce9a434f
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
namespace OCP\AppFramework\Db; namespace OCP\AppFramework\Db;
use function lcfirst;
use function substr;
/** /**
* @method integer getId() * @method integer getId()
* @method void setId(integer $id) * @method void setId(integer $id)
...@@ -139,16 +142,16 @@ abstract class Entity { ...@@ -139,16 +142,16 @@ abstract class Entity {
* getter method * getter method
* @since 7.0.0 * @since 7.0.0
*/ */
public function __call($methodName, $args){ public function __call($methodName, $args) {
$attr = lcfirst( substr($methodName, 3) ); if (strpos($methodName, 'set') === 0) {
$this->setter(lcfirst(substr($methodName, 3)), $args);
if(strpos($methodName, 'set') === 0){ } elseif (strpos($methodName, 'get') === 0) {
$this->setter($attr, $args); return $this->getter(lcfirst(substr($methodName, 3)));
} elseif(strpos($methodName, 'get') === 0) { } elseif (strpos($methodName, 'is') === 0) {
return $this->getter($attr); return $this->getter(lcfirst(substr($methodName, 2)));
} else { } else {
throw new \BadFunctionCallException($methodName . throw new \BadFunctionCallException($methodName .
' does not exist'); ' does not exist');
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment