for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Ganga\Potato;
use SQLite3;
/**
* Class to define connection to sqlite database;
*/
class Connection
{
protected static $conn;
* Constructor
* Declare an instance of SQLite class
public function __construct($config)
if (!is_array($config)) {
throw new PotatoException("Database Config must be an array");
}
if (!isset($config['type']) || empty($config['type'])) {
throw new PotatoException("You must specify a database type in the config");
if (!isset($config['database']) || empty($config['database'])) {
throw new PotatoException("You must provide a database in the config");
$type = strtolower($config['type']);
switch ($type) {
case 'sqlite':
self::$conn = $this->connectSQLite($config);
break;
case 'mysql':
case 'postgres':
case 'pgssql':
case 'mongo':
* Get an instance of the db connection
* @return SQLite3 connection
public static function db()
return self::$conn;
public function connectMySQL()
public function connectSQLite($config)
$conn = new SQLite3($config['database']);
if (!$conn) {
return $conn->lastErrorMsg();
} else {
return $conn;
public function connectPostrges()