Example #1
0
 /**
  * Return session specific config based on the name.
  * Giving all session config instead if name is not provided.
  *
  * @param mixed $name
  */
 public function getConfig($name = null)
 {
     if (empty($name)) {
         return $this->config;
     }
     return $this->app->arrGet($name, $this->config);
 }
Example #2
0
 /**
  * Get the particular token value based on the key.
  * Return all params if key is not provided.
  *
  * @param mixed $key
  */
 public function getParams($key = null)
 {
     if (empty($key)) {
         return $this->params;
     }
     return $this->app->arrGet($key, $this->params, null);
 }
Example #3
0
 /**
  * Get IP address.
  *
  * @return mixed
  */
 public function getIpAddress()
 {
     $ipAddress = $this->app->arrGet('REMOTE_ADDR', $_SERVER);
     foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR'] as $key) {
         if (!empty($this->app->arrGet($key, $_SERVER))) {
             $ipAddress = $this->app->arrGet($key, $_SERVER);
             break;
         }
     }
     return $ipAddress;
 }
Example #4
0
 /**
  * Establish database connection via PDO instance with config.
  *
  * @param  array  $config
  * @return object
  */
 public function createPdo(array $config)
 {
     try {
         extract(array_merge($this->config, $config));
         // replace with user's driver option, if any
         $options = array_replace($this->config['options'], $this->app->arrGet('options', $config, []));
         return new PDO($dsn, $username, $password, $options);
     } catch (\PDOException $e) {
         throw new \RuntimeException($e->getMessage(), $e->getCode());
     }
 }
Example #5
0
 /**
  * Get magic method.
  *
  * @param  mixed $key
  * @return mixed
  */
 public function __get($key)
 {
     return $this->app->arrGet($key, $this->params);
 }
Example #6
0
 /**
  * Get the header description based on the key.
  *
  * @param  mixed $key
  * @return mixed
  */
 public function getHeader($key)
 {
     return $this->app->arrGet($key, $this->headers);
 }