@@ -10,5 +10,5 @@ |
||
| 10 | 10 | |
| 11 | 11 | class Inflector { |
| 12 | 12 | |
| 13 | - use Inflector; |
|
| 13 | + use Inflector; |
|
| 14 | 14 | } |
@@ -14,75 +14,75 @@ |
||
| 14 | 14 | |
| 15 | 15 | class DatabaseConnection extends PDO { |
| 16 | 16 | |
| 17 | - private $databaseName; |
|
| 18 | - private $databaseHost; |
|
| 19 | - private $databaseDriver; |
|
| 20 | - private $databaseUsername; |
|
| 21 | - private $databasePassword; |
|
| 17 | + private $databaseName; |
|
| 18 | + private $databaseHost; |
|
| 19 | + private $databaseDriver; |
|
| 20 | + private $databaseUsername; |
|
| 21 | + private $databasePassword; |
|
| 22 | 22 | |
| 23 | - public function __construct() |
|
| 24 | - { |
|
| 25 | - $this->loadEnv(); // load the environment variables |
|
| 23 | + public function __construct() |
|
| 24 | + { |
|
| 25 | + $this->loadEnv(); // load the environment variables |
|
| 26 | 26 | |
| 27 | - $this->databaseName = getenv('databaseName'); |
|
| 28 | - $this->databaseHost = getenv('databaseHost'); |
|
| 29 | - $this->databaseDriver = getenv('databaseDriver'); |
|
| 30 | - $this->databaseUsername = getenv('databaseUsername'); |
|
| 31 | - $this->databasePassword = getenv('databasePassword'); |
|
| 27 | + $this->databaseName = getenv('databaseName'); |
|
| 28 | + $this->databaseHost = getenv('databaseHost'); |
|
| 29 | + $this->databaseDriver = getenv('databaseDriver'); |
|
| 30 | + $this->databaseUsername = getenv('databaseUsername'); |
|
| 31 | + $this->databasePassword = getenv('databasePassword'); |
|
| 32 | 32 | |
| 33 | - try { |
|
| 34 | - $options = [ |
|
| 35 | - PDO::ATTR_PERSISTENT => true, |
|
| 36 | - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
| 37 | - ]; |
|
| 33 | + try { |
|
| 34 | + $options = [ |
|
| 35 | + PDO::ATTR_PERSISTENT => true, |
|
| 36 | + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
|
| 37 | + ]; |
|
| 38 | 38 | |
| 39 | - parent::__construct($this->getDatabaseDriver(), $this->databaseUsername, $this->databasePassword, $options); |
|
| 39 | + parent::__construct($this->getDatabaseDriver(), $this->databaseUsername, $this->databasePassword, $options); |
|
| 40 | 40 | |
| 41 | - } catch(PDOException $e) { |
|
| 42 | - return $e->getMessage(); |
|
| 41 | + } catch(PDOException $e) { |
|
| 42 | + return $e->getMessage(); |
|
| 43 | 43 | |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * This method determines the driver to be used for appropriate database server |
|
| 50 | - * @params void |
|
| 51 | - * @return string dsn |
|
| 52 | - */ |
|
| 53 | - public function getDatabaseDriver() |
|
| 54 | - { |
|
| 55 | - $dsn = ""; |
|
| 48 | + /** |
|
| 49 | + * This method determines the driver to be used for appropriate database server |
|
| 50 | + * @params void |
|
| 51 | + * @return string dsn |
|
| 52 | + */ |
|
| 53 | + public function getDatabaseDriver() |
|
| 54 | + { |
|
| 55 | + $dsn = ""; |
|
| 56 | 56 | |
| 57 | - switch ($this->databaseDriver) { |
|
| 58 | - case 'mysql': |
|
| 59 | - $dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName; // Set DSN |
|
| 60 | - break; |
|
| 61 | - case 'sqlite': |
|
| 62 | - $dsn = 'sqlite:host='.$this->databaseHost.';dbname='.$this->databaseName; |
|
| 63 | - break; |
|
| 64 | - case 'pgsql': |
|
| 65 | - $dsn = 'pgsqlsql:host='.$this->databaseHost.';dbname='.$this->databaseName; |
|
| 66 | - break; |
|
| 67 | - default: |
|
| 68 | - $dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName; |
|
| 69 | - break; |
|
| 70 | - } |
|
| 57 | + switch ($this->databaseDriver) { |
|
| 58 | + case 'mysql': |
|
| 59 | + $dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName; // Set DSN |
|
| 60 | + break; |
|
| 61 | + case 'sqlite': |
|
| 62 | + $dsn = 'sqlite:host='.$this->databaseHost.';dbname='.$this->databaseName; |
|
| 63 | + break; |
|
| 64 | + case 'pgsql': |
|
| 65 | + $dsn = 'pgsqlsql:host='.$this->databaseHost.';dbname='.$this->databaseName; |
|
| 66 | + break; |
|
| 67 | + default: |
|
| 68 | + $dsn = 'mysql:host='.$this->databaseHost.';dbname='.$this->databaseName; |
|
| 69 | + break; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return $dsn; |
|
| 72 | + return $dsn; |
|
| 73 | 73 | |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Load Dotenv to grant getenv() access to environment variables in .env file |
|
| 78 | - */ |
|
| 79 | - public function loadEnv() |
|
| 80 | - { |
|
| 81 | - if (! getenv("APP_ENV")) { |
|
| 82 | - $dotenv = new Dotenv(__DIR__.'/../../'); |
|
| 83 | - $dotenv->load(); |
|
| 84 | - } |
|
| 76 | + /** |
|
| 77 | + * Load Dotenv to grant getenv() access to environment variables in .env file |
|
| 78 | + */ |
|
| 79 | + public function loadEnv() |
|
| 80 | + { |
|
| 81 | + if (! getenv("APP_ENV")) { |
|
| 82 | + $dotenv = new Dotenv(__DIR__.'/../../'); |
|
| 83 | + $dotenv->load(); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NullArgumentPassedToFunction extends Exception { |
| 14 | 14 | |
| 15 | - public static function create($message) |
|
| 16 | - { |
|
| 17 | - return new static ($message); |
|
| 15 | + public static function create($message) |
|
| 16 | + { |
|
| 17 | + return new static ($message); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
@@ -12,12 +12,12 @@ |
||
| 12 | 12 | |
| 13 | 13 | class TableFieldUndefinedException extends Exception { |
| 14 | 14 | |
| 15 | - public static function create($unExpectedFields, $message) |
|
| 16 | - { |
|
| 17 | - $fields = implode(", ", $unExpectedFields); |
|
| 15 | + public static function create($unExpectedFields, $message) |
|
| 16 | + { |
|
| 17 | + $fields = implode(", ", $unExpectedFields); |
|
| 18 | 18 | |
| 19 | - return new static($fields." ".$message); |
|
| 19 | + return new static($fields." ".$message); |
|
| 20 | 20 | |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | \ No newline at end of file |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoRecordInsertionException extends Exception { |
| 14 | 14 | |
| 15 | - public static function create($mesaage) |
|
| 16 | - { |
|
| 17 | - return new static($mesaage); |
|
| 15 | + public static function create($mesaage) |
|
| 16 | + { |
|
| 17 | + return new static($mesaage); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | |
| 13 | 13 | class WrongArgumentException extends Exception { |
| 14 | 14 | |
| 15 | - public function create($message) |
|
| 16 | - { |
|
| 17 | - return new static ($message); |
|
| 15 | + public function create($message) |
|
| 16 | + { |
|
| 17 | + return new static ($message); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoRecordDeletionException extends Exception |
| 14 | 14 | { |
| 15 | - public static function create($message) |
|
| 16 | - { |
|
| 17 | - return new static($message); |
|
| 15 | + public static function create($message) |
|
| 16 | + { |
|
| 17 | + return new static($message); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoRecordDeletionException extends Exception |
| 14 | 14 | { |
| 15 | - public static function create($message) |
|
| 16 | - { |
|
| 17 | - return new static($message); |
|
| 15 | + public static function create($message) |
|
| 16 | + { |
|
| 17 | + return new static($message); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |
@@ -12,9 +12,9 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NoRecordDeletionException extends Exception |
| 14 | 14 | { |
| 15 | - public static function create($message) |
|
| 16 | - { |
|
| 17 | - return new static($message); |
|
| 15 | + public static function create($message) |
|
| 16 | + { |
|
| 17 | + return new static($message); |
|
| 18 | 18 | |
| 19 | - } |
|
| 19 | + } |
|
| 20 | 20 | } |