src/Koldy/Config.php
public function get(string $key, $defaultValue = null)
    {
        if (!is_array($this->data)) {
            throw new ConfigException('Unable to get config data when config wasn\'t loaded for config name=' . $this->name);
        }

        if (!array_key_exists($key, $this->data)) {
            return $defaultValue;
        }

        if (!$this->isPointerConfig()) {
            return $this->data[$key];
        } else {
            // this is pointer config, let's examine what we have
            $counter = 0;

            do {
                if (!isset($this->data[$key])) {
                    throw new ConfigException("Trying to get non-existing config key={$key} in config name={$this->name()} after {$counter} 'redirects'");
                }

                $config = $this->data[$key];

                if (!is_string($config)) {
                    return $config;
                } else {
                    $key = $config;
                }
            } while ($counter++ < 10);
        }

        // if you get to this line, then something is wrong
        throw new ConfigException("{$this} has too many \"redirects\"");
    }
public function get(string $key, $defaultValue = null)
    {
        if (!is_array($this->data)) {
            throw new ConfigException('Unable to get config data when config wasn\'t loaded for config name=' . $this->name);
        }

        if (!array_key_exists($key, $this->data)) {
            return $defaultValue;
        }

        if (!$this->isPointerConfig()) {
            return $this->data[$key];
        } else {
            // this is pointer config, let's examine what we have
            $counter = 0;

            do {
                if (!isset($this->data[$key])) {
                    throw new ConfigException("Trying to get non-existing config key={$key} in config name={$this->name()} after {$counter} 'redirects'");
                }

                $config = $this->data[$key];

                if (!is_string($config)) {
                    return $config;
                } else {
                    $key = $config;
                }
            } while ($counter++ < 10);
        }

        // if you get to this line, then something is wrong
        throw new ConfigException("{$this} has too many \"redirects\"");
    }
public function get ( string $ key , $ defaultValue = null ) { if ( ! is_array ( $ this -> data ) ) { throw new ConfigException ( 'Unable to get config data when config wasn\'t loaded for config name=' . $ this -> name ) ; } if ( ! array_key_exists ( $ key , $ this -> data ) ) { return $ defaultValue ; } if ( ! $ this -> isPointerConfig ( ) ) { return $ this -> data [ $ key ] ; } else { // this is pointer config, let's examine what we have $ counter = 0 ; do { if ( ! isset ( $ this -> data [ $ key ] ) ) { throw new ConfigException ( "Trying to get non-existing config key={$key} in config name={$this->name()} after {$counter} 'redirects'" ) ; } $ config = $ this -> data [ $ key ] ; if ( ! is_string ( $ config ) ) { return $ config ; } else { $ key = $ config ; } } while ( $ counter ++ < 10 ) ; } // if you get to this line, then something is wrong throw new ConfigException ( "{$this} has too many \"redirects\"" ) ; }
Gets the value on requested key. First argument is key's name, second argument is default value you want
to get if key is not set.

@param string $key
@param mixed $defaultValue

@return mixed
@throws ConfigException
Gets the value on requested key . First argument is key s name second argument is default value you want to get if key is not set .