Crunz\Configuration\Configuration::get PHP Method

get() public method

Return a parameter based on a key
public get ( string $key, $default = null ) : string
$key string
return string
    public function get($key, $default = null)
    {
        if (array_key_exists($key, $this->parameters)) {
            return $this->parameters[$key];
        }
        $array = $this->parameters;
        foreach (explode('.', $key) as $segment) {
            if (is_array($array) && array_key_exists($segment, $array)) {
                $array = $array[$segment];
            } else {
                return null;
            }
        }
        return $array;
    }

Usage Example

Beispiel #1
0
 /**
  * Return a configuration value by key
  *
  * @param  string $key
  *
  * @return string
  */
 protected function config($key)
 {
     if (is_null($this->config)) {
         return;
     }
     return $this->config->get($key);
 }