示例#1
0
文件: Response.php 项目: gileson/api
 /**
  * @param $key
  * @param $value
  */
 function setAttribute($key, $value)
 {
     $method = str_camel('set_' . $key);
     if (method_exists($this, $method)) {
         call_user_func([$this, $method], $value);
     }
 }
示例#2
0
文件: Model.php 项目: gileson/api
 /**
  * @param $key
  *
  * @return mixed|null
  */
 function getAttribute($key)
 {
     if (!in_array($key, $this->fields)) {
         return null;
     }
     $method = str_camel('get_' . $key);
     if (method_exists($this, $method)) {
         return call_user_func([$this, $method]);
     } elseif (isset($this->attributes[$key])) {
         return $this->attributes[$key];
     }
     return null;
 }