Gc\Core\Object::__call PHP Method

__call() public method

Set/Get attribute wrapper
public __call ( string $method, array $args ) : mixed | Object
$method string Method
$args array Arguments
return mixed | Object
    public function __call($method, $args)
    {
        switch (substr($method, 0, 3)) {
            case 'get':
                $key = $this->underscore(substr($method, 3));
                $data = $this->getData($key, isset($args[0]) ? $args[0] : null);
                return $data;
            case 'set':
                $key = $this->underscore(substr($method, 3));
                $result = $this->setData($key, isset($args[0]) ? $args[0] : null);
                return $result;
            case 'uns':
                $key = $this->underscore(substr($method, 3));
                $result = $this->unsetData($key);
                return $result;
            case 'has':
                $key = $this->underscore(substr($method, 3));
                return isset($this->data[$key]);
        }
        throw new \Gc\Exception('Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')');
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Set/Get attribute wrapper
  *
  * @param string $method Method
  * @param array  $args   Args
  *
  * @return  \Zend\Db\TableGateway\TableGateway
  */
 public function __call($method, $args)
 {
     if (empty(self::$tables[$this->name])) {
         $this->__construct();
     }
     if (method_exists(self::$tables[$this->name], $method)) {
         return call_user_func_array(array(self::$tables[$this->name], $method), $args);
     }
     return parent::__call($method, $args);
 }