original_string: public static function setConfig($key, $config = null)
      {
          if ($config === null) {
              if (!is_array($key)) {
                  throw new LogicException('If config is null, key must be an array.');
              }
              foreach ($key as $name => $settings) {
                  static::setConfig($name, $settings);
              }
  
              return;
          }
  
          if (isset(static::$_config[$key])) {
              throw new BadMethodCallException(sprintf('Cannot reconfigure existing key "%s"', $key));
          }
  
          if (is_object($config)) {
              $config = ['className' => $config];
          }
  
          if (isset($config['url'])) {
              $parsed = static::parseDsn($config['url']);
              unset($config['url']);
              $config = $parsed + $config;
          }
  
          if (isset($config['engine']) && empty($config['className'])) {
              $config['className'] = $config['engine'];
              unset($config['engine']);
          }
          static::$_config[$key] = $config;
      }
code: public static function setConfig($key, $config = null)
      {
          if ($config === null) {
              if (!is_array($key)) {
                  throw new LogicException('If config is null, key must be an array.');
              }
              foreach ($key as $name => $settings) {
                  static::setConfig($name, $settings);
              }
  
              return;
          }
  
          if (isset(static::$_config[$key])) {
              throw new BadMethodCallException(sprintf('Cannot reconfigure existing key "%s"', $key));
          }
  
          if (is_object($config)) {
              $config = ['className' => $config];
          }
  
          if (isset($config['url'])) {
              $parsed = static::parseDsn($config['url']);
              unset($config['url']);
              $config = $parsed + $config;
          }
  
          if (isset($config['engine']) && empty($config['className'])) {
              $config['className'] = $config['engine'];
              unset($config['engine']);
          }
          static::$_config[$key] = $config;
      }
code_tokens: public static function setConfig ( $ key , $ config = null ) { if ( $ config === null ) { if ( ! is_array ( $ key ) ) { throw new LogicException ( 'If config is null, key must be an array.' ) ; } foreach ( $ key as $ name => $ settings ) { static :: setConfig ( $ name , $ settings ) ; } return ; } if ( isset ( static :: $ _config [ $ key ] ) ) { throw new BadMethodCallException ( sprintf ( 'Cannot reconfigure existing key "%s"' , $ key ) ) ; } if ( is_object ( $ config ) ) { $ config = [ 'className' => $ config ] ; } if ( isset ( $ config [ 'url' ] ) ) { $ parsed = static :: parseDsn ( $ config [ 'url' ] ) ; unset ( $ config [ 'url' ] ) ; $ config = $ parsed + $ config ; } if ( isset ( $ config [ 'engine' ] ) && empty ( $ config [ 'className' ] ) ) { $ config [ 'className' ] = $ config [ 'engine' ] ; unset ( $ config [ 'engine' ] ) ; } static :: $ _config [ $ key ] = $ config ; }
docstring: This method can be used to define configuration adapters for an application.
  
  To change an adapter's configuration at runtime, first drop the adapter and then
  reconfigure it.
  
  Adapters will not be constructed until the first operation is done.
  
  ### Usage
  
  Assuming that the class' name is `Cache` the following scenarios
  are supported:
  
  Setting a cache engine up.
  
  ```
  Cache::setConfig('default', $settings);
  ```
  
  Injecting a constructed adapter in:
  
  ```
  Cache::setConfig('default', $instance);
  ```
  
  Configure multiple adapters at once:
  
  ```
  Cache::setConfig($arrayOfConfig);
  ```
  
  @param string|array $key The name of the configuration, or an array of multiple configs.
  @param array $config An array of name => configuration data for adapter.
  @throws \BadMethodCallException When trying to modify an existing config.
  @throws \LogicException When trying to store an invalid structured config array.
  @return void
docstring_tokens: This method can be used to define configuration adapters for an application .