Esempio n. 1
0
 /**
  * @param $key
  * @param $value
  */
 function setAttribute($key, $value)
 {
     $method = str_camel('set_' . $key);
     if (method_exists($this, $method)) {
         call_user_func([$this, $method], $value);
     }
 }
Esempio n. 2
0
 /**
  * @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;
 }