Ejemplo n.º 1
0
 public function __call($func, $args)
 {
     if (preg_match("/get(\\w+)/", $func, $matches)) {
         $key = strtolower($matches[1]);
         $value = $this->{$key};
         if ($value) {
             return htmlspecialchars($value);
         }
         if (!array_key_exists($key, $this->_defaultValues)) {
             throw new Exception("No default value for {$key}");
         }
         return $this->_defaultValues[$key];
     } else {
         parent::__call($func, $args);
     }
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  * @internal
  */
 public function __call($method, array $args)
 {
     $column = String::dasherize(substr($method, 3));
     $isSetterOrGetter = substr($method, 0, 3);
     if ('get' === $isSetterOrGetter && $this->offsetExists($column)) {
         return $this->__get($column);
     } elseif ('set' === $isSetterOrGetter && $this->offsetExists($column)) {
         return $this->__set($column, $args[0]);
     } else {
         return parent::__call($method, $args);
     }
 }