refactoring for dependency injection and testability.

This commit is contained in:
Taylor Otwell
2011-08-25 22:53:05 -05:00
parent 0b86c94551
commit 1e7850d9ba
75 changed files with 1441 additions and 1461 deletions

View File

@@ -0,0 +1,30 @@
<?php namespace Laravel\DB\Connector;
class Factory {
/**
* Create a new database connector instance for a given driver.
*
* @param array $config
* @return Connector
*/
public static function make($config)
{
if (isset($config['connector'])) return new Callback;
switch ($config['driver'])
{
case 'sqlite':
return new SQLite;
case 'mysql':
return new MySQL;
case 'pgsql':
return new Postgres;
}
throw new \Exception("Database configuration is invalid. Please verify your configuration.");
}
}