Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function __call($name, $args) {
- if(strpos($name, 'get') === 0) {
- return $this->__get(strtolower(substr($name, 3, 1)) . substr($name, 4));
- } elseif(strpos($name, 'set') === 0) {
- return $this->__set(strtolower(substr($name, 3, 1)) . substr($name, 4), $args);
- } elseif(strpos($name, 'is') === 0) {
- $val = $this->__get(strtolower(substr($name, 3, 1)) . substr($name, 4));
- return !empty($val);
- }
- }
- public function __get($name) {
- $m = 'get' . ucfirst($name);
- if(method_exists($this, $m)) {
- return $this->$m();
- }
- if(property_exists($this, $name)) {
- return $this->$name;
- }
- }
- public function __set($name, $value) {
- $m = 'set' . ucfirst($name);
- if(method_exists($this, $m)) {
- return $this->$m($value);
- }
- if(property_exists($this, $name) || $name == 'id' || $name == 'machine' || $name == 'discriminator') {
- $this->$name = $value;
- } else {
- //drupalwiki_spaces_log('no property with name ' . $name . ' in ' . get_class($this));
- }
- }
Add Comment
Please, Sign In to add comment