Guest User

Untitled

a guest
Feb 19th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1.  public function __call($name, $args) {
  2.     if(strpos($name, 'get') === 0) {
  3.       return $this->__get(strtolower(substr($name, 3, 1)) . substr($name, 4));
  4.     } elseif(strpos($name, 'set') === 0) {
  5.       return $this->__set(strtolower(substr($name, 3, 1)) . substr($name, 4), $args);
  6.     } elseif(strpos($name, 'is') === 0) {
  7.       $val = $this->__get(strtolower(substr($name, 3, 1)) . substr($name, 4));
  8.       return !empty($val);
  9.     }
  10.   }
  11.  
  12.   public function __get($name) {
  13.     $m = 'get' . ucfirst($name);
  14.     if(method_exists($this, $m)) {
  15.       return $this->$m();
  16.     }
  17.     if(property_exists($this, $name)) {
  18.       return $this->$name;
  19.     }
  20.   }
  21.  
  22.   public function __set($name, $value) {
  23.     $m = 'set' . ucfirst($name);
  24.     if(method_exists($this, $m)) {
  25.       return $this->$m($value);
  26.     }
  27.     if(property_exists($this, $name) || $name == 'id' || $name == 'machine' || $name == 'discriminator') {
  28.       $this->$name = $value;
  29.     } else {
  30.       //drupalwiki_spaces_log('no property with name ' . $name . ' in ' . get_class($this));
  31.     }
  32.   }
Add Comment
Please, Sign In to add comment