factory.php 549 B

123456789101112131415161718192021222324252627282930
  1. <?php namespace Laravel\DB\Connector;
  2. class Factory {
  3. /**
  4. * Create a new database connector instance for a given driver.
  5. *
  6. * @param array $config
  7. * @return Connector
  8. */
  9. public static function make($config)
  10. {
  11. if (isset($config['connector'])) return new Callback;
  12. switch ($config['driver'])
  13. {
  14. case 'sqlite':
  15. return new SQLite;
  16. case 'mysql':
  17. return new MySQL;
  18. case 'pgsql':
  19. return new Postgres;
  20. }
  21. throw new \Exception("Database configuration is invalid. Please verify your configuration.");
  22. }
  23. }