get() public method

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)
return string | integer | float | boolean | array
Esempio n. 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;
 }
Esempio n. 2
0
 /**
  * Dump configuration to the related config-file.
  *
  * The config-file is automatically determined using
  * type.
  *
  * @param Config $config
  * @param string $type
  *
  * @return string
  */
 public static function dumpToFile(Config $config, $type)
 {
     if ($type === Config::CONFIG_LOCAL) {
         $filename = $config->get('local_config');
         if (null === $filename) {
             throw new \RuntimeException('Local configuration is not loaded and therefore it cannot be dumped.');
         }
     } elseif ($type === Config::CONFIG_SYSTEM) {
         $filename = $config->get('home_config');
     } else {
         throw new \InvalidArgumentException(sprintf('Config slot "%s" is not valid for dumping to a file "%s", use either: ' . 'Config::CONFIG_SYSTEM or Config::CONFIG_LOCAL.', $type));
     }
     // Testing compatibility, write directly as there is no risk of problems
     if ('vfs://' === substr($filename, 0, 6)) {
         file_put_contents($filename, Yaml::dump($config->toArray($type)));
     } else {
         self::getFilesystem()->dumpFile($filename, "# Gush configuration file, any comments will be lost.\n" . Yaml::dump($config->toArray($type), 2));
     }
     return $filename;
 }