Gush\Config::get PHP Метод

get() публичный Метод

Returns a config value.
public get ( string | string[] $keys, string $type = self::CONFIG_ALL, string | integer | float | boolean | array $default = null ) : string | integer | float | boolean | array
$keys string | string[] Single level key like 'adapters' or array-path like ['adapters', 'github']
$type string Either Config::CONFIG_SYSTEM Config::CONFIG_LOCAL or Config::CONFIG_ALL
$default string | integer | float | boolean | array Default value to use when no config is found (null)
Результат string | integer | float | boolean | array
    public function get($keys, $type = self::CONFIG_ALL, $default = null)
    {
        $this->guardConfigSlot($type);
        $keys = (array) $keys;
        if (count($keys) === 1) {
            return array_key_exists($keys[0], $this->config[$type]) ? $this->config[$type][$keys[0]] : $default;
        }
        $current = $this->config[$type];
        foreach ($keys as $key) {
            if (!is_array($current) || !array_key_exists($key, $current)) {
                return $default;
            }
            $current = $current[$key];
        }
        return $current;
    }

Usage Example

Пример #1
0
 /**
  * @return Client
  */
 protected function buildGitHubClient()
 {
     $cachedClient = new CachedHttpClient(['cache_dir' => $this->globalConfig->get('cache-dir'), 'base_url' => $this->config['base_url']]);
     $client = new Client($cachedClient);
     if (false !== getenv('GITHUB_DEBUG')) {
         $logPlugin = LogPlugin::getDebugPlugin();
         $httpClient = $client->getHttpClient();
         $httpClient->addSubscriber($logPlugin);
     }
     $client->setOption('base_url', $this->config['base_url']);
     $this->url = rtrim($this->config['base_url'], '/');
     $this->domain = rtrim($this->config['repo_domain_url'], '/');
     return $client;
 }
All Usage Examples Of Gush\Config::get