瀏覽代碼

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

Add isXXX getter to Entity
tags/v18.0.0beta1
Roeland Jago Douma 4 年之前
父節點
當前提交
7960a71fe2
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 12 行新增9 行删除
  1. 12
    9
      lib/public/AppFramework/Db/Entity.php

+ 12
- 9
lib/public/AppFramework/Db/Entity.php 查看文件

@@ -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');
}

}

Loading…
取消
儲存