original_string: public static function factory($adapter, $config = array())
      {
          if ($config instanceof Zend_Config) {
              $config = $config->toArray();
          }
  
          /*
           * Convert Zend_Config argument to plain string
           * adapter name and separate config object.
           */
          if ($adapter instanceof Zend_Config) {
              if (isset($adapter->params)) {
                  $config = $adapter->params->toArray();
              }
              if (isset($adapter->adapter)) {
                  $adapter = (string) $adapter->adapter;
              } else {
                  $adapter = null;
              }
          }
  
          /*
           * Verify that adapter parameters are in an array.
           */
          if (!is_array($config)) {
              /**
               * @see Zend_Db_Exception
               */
              // require_once 'Zend/Db/Exception.php';
              throw new Zend_Db_Exception('Adapter parameters must be in an array or a Zend_Config object');
          }
  
          /*
           * Verify that an adapter name has been specified.
           */
          if (!is_string($adapter) || empty($adapter)) {
              /**
               * @see Zend_Db_Exception
               */
              // require_once 'Zend/Db/Exception.php';
              throw new Zend_Db_Exception('Adapter name must be specified in a string');
          }
  
          /*
           * Form full adapter class name
           */
          $adapterNamespace = 'Zend_Db_Adapter';
          if (isset($config['adapterNamespace'])) {
              if ($config['adapterNamespace'] != '') {
                  $adapterNamespace = $config['adapterNamespace'];
              }
              unset($config['adapterNamespace']);
          }
  
          // Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606
          $adapterName = $adapterNamespace . '_';
          $adapterName .= str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($adapter))));
  
          /*
           * Load the adapter class.  This throws an exception
           * if the specified class cannot be loaded.
           */
          if (!class_exists($adapterName)) {
              // require_once 'Zend/Loader.php';
              Zend_Loader::loadClass($adapterName);
          }
  
          /*
           * Create an instance of the adapter class.
           * Pass the config to the adapter class constructor.
           */
          $dbAdapter = new $adapterName($config);
  
          /*
           * Verify that the object created is a descendent of the abstract adapter type.
           */
          if (! $dbAdapter instanceof Zend_Db_Adapter_Abstract) {
              /**
               * @see Zend_Db_Exception
               */
              // require_once 'Zend/Db/Exception.php';
              throw new Zend_Db_Exception("Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract");
          }
  
          return $dbAdapter;
      }
code: public static function factory($adapter, $config = array())
      {
          if ($config instanceof Zend_Config) {
              $config = $config->toArray();
          }
  
          /*
           * Convert Zend_Config argument to plain string
           * adapter name and separate config object.
           */
          if ($adapter instanceof Zend_Config) {
              if (isset($adapter->params)) {
                  $config = $adapter->params->toArray();
              }
              if (isset($adapter->adapter)) {
                  $adapter = (string) $adapter->adapter;
              } else {
                  $adapter = null;
              }
          }
  
          /*
           * Verify that adapter parameters are in an array.
           */
          if (!is_array($config)) {
              /**
               * @see Zend_Db_Exception
               */
              // require_once 'Zend/Db/Exception.php';
              throw new Zend_Db_Exception('Adapter parameters must be in an array or a Zend_Config object');
          }
  
          /*
           * Verify that an adapter name has been specified.
           */
          if (!is_string($adapter) || empty($adapter)) {
              /**
               * @see Zend_Db_Exception
               */
              // require_once 'Zend/Db/Exception.php';
              throw new Zend_Db_Exception('Adapter name must be specified in a string');
          }
  
          /*
           * Form full adapter class name
           */
          $adapterNamespace = 'Zend_Db_Adapter';
          if (isset($config['adapterNamespace'])) {
              if ($config['adapterNamespace'] != '') {
                  $adapterNamespace = $config['adapterNamespace'];
              }
              unset($config['adapterNamespace']);
          }
  
          // Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606
          $adapterName = $adapterNamespace . '_';
          $adapterName .= str_replace(' ', '_', ucwords(str_replace('_', ' ', strtolower($adapter))));
  
          /*
           * Load the adapter class.  This throws an exception
           * if the specified class cannot be loaded.
           */
          if (!class_exists($adapterName)) {
              // require_once 'Zend/Loader.php';
              Zend_Loader::loadClass($adapterName);
          }
  
          /*
           * Create an instance of the adapter class.
           * Pass the config to the adapter class constructor.
           */
          $dbAdapter = new $adapterName($config);
  
          /*
           * Verify that the object created is a descendent of the abstract adapter type.
           */
          if (! $dbAdapter instanceof Zend_Db_Adapter_Abstract) {
              /**
               * @see Zend_Db_Exception
               */
              // require_once 'Zend/Db/Exception.php';
              throw new Zend_Db_Exception("Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract");
          }
  
          return $dbAdapter;
      }
code_tokens: public static function factory ( $ adapter , $ config = array ( ) ) { if ( $ config instanceof Zend_Config ) { $ config = $ config -> toArray ( ) ; } /*
           * Convert Zend_Config argument to plain string
           * adapter name and separate config object.
           */ if ( $ adapter instanceof Zend_Config ) { if ( isset ( $ adapter -> params ) ) { $ config = $ adapter -> params -> toArray ( ) ; } if ( isset ( $ adapter -> adapter ) ) { $ adapter = ( string ) $ adapter -> adapter ; } else { $ adapter = null ; } } /*
           * Verify that adapter parameters are in an array.
           */ if ( ! is_array ( $ config ) ) { /**
               * @see Zend_Db_Exception
               */ // require_once 'Zend/Db/Exception.php'; throw new Zend_Db_Exception ( 'Adapter parameters must be in an array or a Zend_Config object' ) ; } /*
           * Verify that an adapter name has been specified.
           */ if ( ! is_string ( $ adapter ) || empty ( $ adapter ) ) { /**
               * @see Zend_Db_Exception
               */ // require_once 'Zend/Db/Exception.php'; throw new Zend_Db_Exception ( 'Adapter name must be specified in a string' ) ; } /*
           * Form full adapter class name
           */ $ adapterNamespace = 'Zend_Db_Adapter' ; if ( isset ( $ config [ 'adapterNamespace' ] ) ) { if ( $ config [ 'adapterNamespace' ] != '' ) { $ adapterNamespace = $ config [ 'adapterNamespace' ] ; } unset ( $ config [ 'adapterNamespace' ] ) ; } // Adapter no longer normalized- see http://framework.zend.com/issues/browse/ZF-5606 $ adapterName = $ adapterNamespace . '_' ; $ adapterName .= str_replace ( ' ' , '_' , ucwords ( str_replace ( '_' , ' ' , strtolower ( $ adapter ) ) ) ) ; /*
           * Load the adapter class.  This throws an exception
           * if the specified class cannot be loaded.
           */ if ( ! class_exists ( $ adapterName ) ) { // require_once 'Zend/Loader.php'; Zend_Loader :: loadClass ( $ adapterName ) ; } /*
           * Create an instance of the adapter class.
           * Pass the config to the adapter class constructor.
           */ $ dbAdapter = new $ adapterName ( $ config ) ; /*
           * Verify that the object created is a descendent of the abstract adapter type.
           */ if ( ! $ dbAdapter instanceof Zend_Db_Adapter_Abstract ) { /**
               * @see Zend_Db_Exception
               */ // require_once 'Zend/Db/Exception.php'; throw new Zend_Db_Exception ( "Adapter class '$adapterName' does not extend Zend_Db_Adapter_Abstract" ) ; } return $ dbAdapter ; }
docstring: Factory for Zend_Db_Adapter_Abstract classes.
  
  First argument may be a string containing the base of the adapter class
  name, e.g. 'Mysqli' corresponds to class Zend_Db_Adapter_Mysqli.  This
  name is currently case-insensitive, but is not ideal to rely on this behavior.
  If your class is named 'My_Company_Pdo_Mysql', where 'My_Company' is the namespace
  and 'Pdo_Mysql' is the adapter name, it is best to use the name exactly as it
  is defined in the class.  This will ensure proper use of the factory API.
  
  First argument may alternatively be an object of type Zend_Config.
  The adapter class base name is read from the 'adapter' property.
  The adapter config parameters are read from the 'params' property.
  
  Second argument is optional and may be an associative array of key-value
  pairs.  This is used as the argument to the adapter constructor.
  
  If the first argument is of type Zend_Config, it is assumed to contain
  all parameters, and the second argument is ignored.
  
  @param  mixed $adapter String name of base adapter class, or Zend_Config object.
  @param  mixed $config  OPTIONAL; an array or Zend_Config object with adapter parameters.
  @return Zend_Db_Adapter_Abstract
  @throws Zend_Db_Exception
docstring_tokens: Factory for Zend_Db_Adapter_Abstract classes .