@@ -21,106 +21,106 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class SQLite implements ConnectableInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @var string $dsn |
|
| 26 | - */ |
|
| 27 | - protected $dsn; |
|
| 24 | + /** |
|
| 25 | + * @var string $dsn |
|
| 26 | + */ |
|
| 27 | + protected $dsn; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var \PDO $connectionObject |
|
| 31 | - */ |
|
| 32 | - protected $connectionObject; |
|
| 29 | + /** |
|
| 30 | + * @var \PDO $connectionObject |
|
| 31 | + */ |
|
| 32 | + protected $connectionObject; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var array loginData |
|
| 36 | - */ |
|
| 37 | - private $loginData = []; |
|
| 34 | + /** |
|
| 35 | + * @var array loginData |
|
| 36 | + */ |
|
| 37 | + private $loginData = []; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Setter for the DSN string {@see $dsn} |
|
| 41 | - * |
|
| 42 | - * MSSQl Server DSN Structure: sqlsrv:Server={srv};Database={db}" |
|
| 43 | - * `$dsnArray[0] = {srv}` |
|
| 44 | - * `$dsnArray[1] = {db}` |
|
| 45 | - * Attributes = [2 - infinity] |
|
| 46 | - * |
|
| 47 | - * @param array $dsnArray |
|
| 48 | - * @return void |
|
| 49 | - */ |
|
| 50 | - public function setDsn(array $dsnArray) |
|
| 51 | - { |
|
| 52 | - $this->dsn = $dsnArray; |
|
| 53 | - } |
|
| 39 | + /** |
|
| 40 | + * Setter for the DSN string {@see $dsn} |
|
| 41 | + * |
|
| 42 | + * MSSQl Server DSN Structure: sqlsrv:Server={srv};Database={db}" |
|
| 43 | + * `$dsnArray[0] = {srv}` |
|
| 44 | + * `$dsnArray[1] = {db}` |
|
| 45 | + * Attributes = [2 - infinity] |
|
| 46 | + * |
|
| 47 | + * @param array $dsnArray |
|
| 48 | + * @return void |
|
| 49 | + */ |
|
| 50 | + public function setDsn(array $dsnArray) |
|
| 51 | + { |
|
| 52 | + $this->dsn = $dsnArray; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Establishes connection |
|
| 57 | - * |
|
| 58 | - * @param string $username |
|
| 59 | - * @param string $password optional |
|
| 60 | - * @throws \EmmetBlue\Core\Exception\SQLException |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public function connect(string $username="", string $password="") |
|
| 64 | - { |
|
| 65 | - $dbLocation = $this->dsn[0]; |
|
| 55 | + /** |
|
| 56 | + * Establishes connection |
|
| 57 | + * |
|
| 58 | + * @param string $username |
|
| 59 | + * @param string $password optional |
|
| 60 | + * @throws \EmmetBlue\Core\Exception\SQLException |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public function connect(string $username="", string $password="") |
|
| 64 | + { |
|
| 65 | + $dbLocation = $this->dsn[0]; |
|
| 66 | 66 | |
| 67 | - try |
|
| 68 | - { |
|
| 69 | - $this->connectionObject = new \PDO("sqlite:$dbLocation"); |
|
| 70 | - } |
|
| 71 | - catch (\PDOException $e) |
|
| 72 | - { |
|
| 73 | - throw new SQLException("Unable to connect to database", 400, $e); |
|
| 74 | - } |
|
| 67 | + try |
|
| 68 | + { |
|
| 69 | + $this->connectionObject = new \PDO("sqlite:$dbLocation"); |
|
| 70 | + } |
|
| 71 | + catch (\PDOException $e) |
|
| 72 | + { |
|
| 73 | + throw new SQLException("Unable to connect to database", 400, $e); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $dsn = $this->dsn; |
|
| 77 | - unset($dsn[0]); |
|
| 76 | + $dsn = $this->dsn; |
|
| 77 | + unset($dsn[0]); |
|
| 78 | 78 | |
| 79 | - foreach ($dsn as $attribute) |
|
| 80 | - { |
|
| 81 | - foreach ($attribute as $key=>$value) |
|
| 82 | - { |
|
| 83 | - $this->connectionObject->setAttribute($key, $value); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - } |
|
| 79 | + foreach ($dsn as $attribute) |
|
| 80 | + { |
|
| 81 | + foreach ($attribute as $key=>$value) |
|
| 82 | + { |
|
| 83 | + $this->connectionObject->setAttribute($key, $value); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - /** |
|
| 89 | - * Returns an instance a pdo intance of the connection object |
|
| 90 | - * |
|
| 91 | - * @return \PDO |
|
| 92 | - */ |
|
| 93 | - public function getConnection() : \PDO |
|
| 94 | - { |
|
| 95 | - if ($this->connectionObject instanceof \PDO) |
|
| 96 | - { |
|
| 97 | - return $this->connectionObject; |
|
| 98 | - } |
|
| 88 | + /** |
|
| 89 | + * Returns an instance a pdo intance of the connection object |
|
| 90 | + * |
|
| 91 | + * @return \PDO |
|
| 92 | + */ |
|
| 93 | + public function getConnection() : \PDO |
|
| 94 | + { |
|
| 95 | + if ($this->connectionObject instanceof \PDO) |
|
| 96 | + { |
|
| 97 | + return $this->connectionObject; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - $this->connect( |
|
| 101 | - $this->loginData['username'] ?? '', |
|
| 102 | - $this->loginData['password'] ?? '' |
|
| 103 | - ); |
|
| 100 | + $this->connect( |
|
| 101 | + $this->loginData['username'] ?? '', |
|
| 102 | + $this->loginData['password'] ?? '' |
|
| 103 | + ); |
|
| 104 | 104 | |
| 105 | - return $this->connectionObject; |
|
| 106 | - } |
|
| 105 | + return $this->connectionObject; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Closes connection |
|
| 110 | - */ |
|
| 111 | - public function disableConnection() |
|
| 112 | - { |
|
| 113 | - $this->connectionObject = null; |
|
| 114 | - } |
|
| 108 | + /** |
|
| 109 | + * Closes connection |
|
| 110 | + */ |
|
| 111 | + public function disableConnection() |
|
| 112 | + { |
|
| 113 | + $this->connectionObject = null; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - /** |
|
| 117 | - * Sets attributes for the PDO object |
|
| 118 | - * |
|
| 119 | - * @param \PDO $attribute |
|
| 120 | - * @param \PDO $value |
|
| 121 | - */ |
|
| 122 | - public function setAttribute(\PDO $attribute, \PDO $value) |
|
| 123 | - { |
|
| 124 | - $this->connectionObject->setAttribute($attribute, $value); |
|
| 125 | - } |
|
| 116 | + /** |
|
| 117 | + * Sets attributes for the PDO object |
|
| 118 | + * |
|
| 119 | + * @param \PDO $attribute |
|
| 120 | + * @param \PDO $value |
|
| 121 | + */ |
|
| 122 | + public function setAttribute(\PDO $attribute, \PDO $value) |
|
| 123 | + { |
|
| 124 | + $this->connectionObject->setAttribute($attribute, $value); |
|
| 125 | + } |
|
| 126 | 126 | } |
@@ -22,21 +22,21 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class ErrorLog implements LogInterface |
| 24 | 24 | { |
| 25 | - public static function log(int $databaseUserId, string $errorNumber, string $errorSeverity, string $errorMessage, string $errorObject=null) |
|
| 26 | - { |
|
| 27 | - /** |
|
| 28 | - * For now I am not doing anything with $errorObject yet. |
|
| 29 | - * |
|
| 30 | - * As soon as it can be properly serialized for the MSSQL Server db |
|
| 31 | - * it shall be saved in the database. |
|
| 32 | - * |
|
| 33 | - * FUNNY: I'M GONNA INTENTIONALLY LEAVE THIS COMMIT FOR MY AMUSEMENT |
|
| 34 | - * $errorObject, wasn't the issue. My DB schema was. |
|
| 35 | - */ |
|
| 36 | - $insertBuilder = (new Builder("QueryBuilder", "Insert"))->getBuilder(); |
|
| 25 | + public static function log(int $databaseUserId, string $errorNumber, string $errorSeverity, string $errorMessage, string $errorObject=null) |
|
| 26 | + { |
|
| 27 | + /** |
|
| 28 | + * For now I am not doing anything with $errorObject yet. |
|
| 29 | + * |
|
| 30 | + * As soon as it can be properly serialized for the MSSQL Server db |
|
| 31 | + * it shall be saved in the database. |
|
| 32 | + * |
|
| 33 | + * FUNNY: I'M GONNA INTENTIONALLY LEAVE THIS COMMIT FOR MY AMUSEMENT |
|
| 34 | + * $errorObject, wasn't the issue. My DB schema was. |
|
| 35 | + */ |
|
| 36 | + $insertBuilder = (new Builder("QueryBuilder", "Insert"))->getBuilder(); |
|
| 37 | 37 | |
| 38 | - $insertBuilder |
|
| 39 | - ->into(' |
|
| 38 | + $insertBuilder |
|
| 39 | + ->into(' |
|
| 40 | 40 | [Logs].[ErrorLog] |
| 41 | 41 | ( |
| 42 | 42 | ErrorTime, |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | ErrorMessage |
| 47 | 47 | ) |
| 48 | 48 | ') |
| 49 | - ->values([ |
|
| 50 | - 'GETDATE()', |
|
| 51 | - $databaseUserId, |
|
| 52 | - QB::wrapString($errorNumber, "'"), |
|
| 53 | - QB::wrapString($errorSeverity, "'"), |
|
| 54 | - QB::wrapString($errorMessage, "'") |
|
| 55 | - ]); |
|
| 49 | + ->values([ |
|
| 50 | + 'GETDATE()', |
|
| 51 | + $databaseUserId, |
|
| 52 | + QB::wrapString($errorNumber, "'"), |
|
| 53 | + QB::wrapString($errorSeverity, "'"), |
|
| 54 | + QB::wrapString($errorMessage, "'") |
|
| 55 | + ]); |
|
| 56 | 56 | |
| 57 | - DBConnectionFactory::getConnection()->query((string)$insertBuilder); |
|
| 58 | - } |
|
| 57 | + DBConnectionFactory::getConnection()->query((string)$insertBuilder); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -22,12 +22,12 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | class DatabaseLog implements LogInterface |
| 24 | 24 | { |
| 25 | - public static function log(string $databaseUserId, string $event, string $objectSchema, string $object, string $tSql) |
|
| 26 | - { |
|
| 27 | - $insertBuilder = (new Builder("QueryBuilder", "Insert"))->getBuilder(); |
|
| 28 | - try { |
|
| 29 | - $insertBuilder |
|
| 30 | - ->into(' |
|
| 25 | + public static function log(string $databaseUserId, string $event, string $objectSchema, string $object, string $tSql) |
|
| 26 | + { |
|
| 27 | + $insertBuilder = (new Builder("QueryBuilder", "Insert"))->getBuilder(); |
|
| 28 | + try { |
|
| 29 | + $insertBuilder |
|
| 30 | + ->into(' |
|
| 31 | 31 | [Logs].[DatabaseLog] |
| 32 | 32 | ( |
| 33 | 33 | PostTime, |
@@ -38,21 +38,21 @@ discard block |
||
| 38 | 38 | TSQL |
| 39 | 39 | ) |
| 40 | 40 | ') |
| 41 | - ->values([ |
|
| 42 | - 'GETDATE()', |
|
| 43 | - QB::wrapString($databaseUserId, "'"), |
|
| 44 | - QB::wrapString((string)$event, "'"), |
|
| 45 | - QB::wrapString($objectSchema, "'"), |
|
| 46 | - QB::wrapString($object, "'"), |
|
| 47 | - QB::wrapString(str_replace("'", "\"", $tSql), "'") |
|
| 48 | - ]); |
|
| 41 | + ->values([ |
|
| 42 | + 'GETDATE()', |
|
| 43 | + QB::wrapString($databaseUserId, "'"), |
|
| 44 | + QB::wrapString((string)$event, "'"), |
|
| 45 | + QB::wrapString($objectSchema, "'"), |
|
| 46 | + QB::wrapString($object, "'"), |
|
| 47 | + QB::wrapString(str_replace("'", "\"", $tSql), "'") |
|
| 48 | + ]); |
|
| 49 | 49 | |
| 50 | - DBConnectionFactory::getConnection()->query((string)$insertBuilder); |
|
| 51 | - } catch (\PDOException $e) { |
|
| 52 | - echo $e->getMessage(); |
|
| 53 | - throw new SQLException(sprintf( |
|
| 54 | - "Unable to store database log" |
|
| 55 | - ), 1); |
|
| 56 | - } |
|
| 57 | - } |
|
| 50 | + DBConnectionFactory::getConnection()->query((string)$insertBuilder); |
|
| 51 | + } catch (\PDOException $e) { |
|
| 52 | + echo $e->getMessage(); |
|
| 53 | + throw new SQLException(sprintf( |
|
| 54 | + "Unable to store database log" |
|
| 55 | + ), 1); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -17,35 +17,35 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Constant |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Events |
|
| 22 | - */ |
|
| 23 | - const EVENT_INSERT = 'EVENT: INSERT DML EVENT'; |
|
| 24 | - const EVENT_SELECT = 'EVENT: SELECT DML EVENT'; |
|
| 25 | - const EVENT_UPDATE = 'EVENT: UPDATE DML EVENT'; |
|
| 20 | + /** |
|
| 21 | + * Events |
|
| 22 | + */ |
|
| 23 | + const EVENT_INSERT = 'EVENT: INSERT DML EVENT'; |
|
| 24 | + const EVENT_SELECT = 'EVENT: SELECT DML EVENT'; |
|
| 25 | + const EVENT_UPDATE = 'EVENT: UPDATE DML EVENT'; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @author Lucky Bardeson |
|
| 29 | - */ |
|
| 30 | - const EVENT_DELETE = 'EVENT: DELETE DML EVENT'; |
|
| 27 | + /** |
|
| 28 | + * @author Lucky Bardeson |
|
| 29 | + */ |
|
| 30 | + const EVENT_DELETE = 'EVENT: DELETE DML EVENT'; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Error Numbers |
|
| 34 | - */ |
|
| 35 | - const ERROR_401 = 'ERROR_401: Resource Inaccessible'; |
|
| 36 | - const ERROR_402 = 'ERROR_402: Resource Requirements Not Met'; |
|
| 37 | - const ERROR_403 = 'ERROR_403: Resource Not Writable'; |
|
| 38 | - const ERROR_404 = 'ERROR_404: Resource Not Found'; |
|
| 32 | + /** |
|
| 33 | + * Error Numbers |
|
| 34 | + */ |
|
| 35 | + const ERROR_401 = 'ERROR_401: Resource Inaccessible'; |
|
| 36 | + const ERROR_402 = 'ERROR_402: Resource Requirements Not Met'; |
|
| 37 | + const ERROR_403 = 'ERROR_403: Resource Not Writable'; |
|
| 38 | + const ERROR_404 = 'ERROR_404: Resource Not Found'; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Error Severities |
|
| 42 | - */ |
|
| 43 | - const ERROR_HIGH = 'ERROR_SEVERITY: HIGH'; |
|
| 44 | - const ERROR_LOW = 'ERROR_SEVERITY: LOW'; |
|
| 45 | - const ERROR_NORMAL = 'ERROR_SEVERITY: NORMAL'; |
|
| 40 | + /** |
|
| 41 | + * Error Severities |
|
| 42 | + */ |
|
| 43 | + const ERROR_HIGH = 'ERROR_SEVERITY: HIGH'; |
|
| 44 | + const ERROR_LOW = 'ERROR_SEVERITY: LOW'; |
|
| 45 | + const ERROR_NORMAL = 'ERROR_SEVERITY: NORMAL'; |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * |
|
| 49 | - */ |
|
| 50 | - const UNDEFINED = 0; |
|
| 47 | + /** |
|
| 48 | + * |
|
| 49 | + */ |
|
| 50 | + const UNDEFINED = 0; |
|
| 51 | 51 | } |
@@ -17,84 +17,84 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class SelectQueryBuilder extends QueryBuilder |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var \EmmetBlue\Core\Builder\QueryBuilder |
|
| 22 | - */ |
|
| 23 | - protected $queryBuilder; |
|
| 20 | + /** |
|
| 21 | + * @var \EmmetBlue\Core\Builder\QueryBuilder |
|
| 22 | + */ |
|
| 23 | + protected $queryBuilder; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param string|null $tableName |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - $SelectKeyword = "SELECT"; |
|
| 31 | - $this->queryBuilder = $this->build($SelectKeyword); |
|
| 32 | - } |
|
| 25 | + /** |
|
| 26 | + * @param string|null $tableName |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + $SelectKeyword = "SELECT"; |
|
| 31 | + $this->queryBuilder = $this->build($SelectKeyword); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - * |
|
| 37 | - * @param int $topValue |
|
| 38 | - * |
|
| 39 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 40 | - */ |
|
| 41 | - public function top(int $topValue) |
|
| 42 | - { |
|
| 43 | - $this->queryBuilder = $this->queryBuilder->build("TOP ".$topValue); |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + * |
|
| 37 | + * @param int $topValue |
|
| 38 | + * |
|
| 39 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 40 | + */ |
|
| 41 | + public function top(int $topValue) |
|
| 42 | + { |
|
| 43 | + $this->queryBuilder = $this->queryBuilder->build("TOP ".$topValue); |
|
| 44 | 44 | |
| 45 | - return $this; |
|
| 46 | - } |
|
| 47 | - /** |
|
| 48 | - * This method handles situations that requires to |
|
| 49 | - * select all from the table. |
|
| 50 | - * @param * |
|
| 51 | - */ |
|
| 52 | - public function all() |
|
| 53 | - { |
|
| 54 | - $this->queryBuilder = $this->queryBuilder->build("*"); |
|
| 55 | - return $this; |
|
| 56 | - } |
|
| 57 | - /** |
|
| 58 | - * {@inheritdoc} |
|
| 59 | - * |
|
| 60 | - * @param string $columns |
|
| 61 | - * |
|
| 62 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 63 | - */ |
|
| 64 | - public function columns(string ...$columns) |
|
| 65 | - { |
|
| 66 | - $this->queryBuilder = $this->queryBuilder->build(self::getImplodedString($columns)); |
|
| 45 | + return $this; |
|
| 46 | + } |
|
| 47 | + /** |
|
| 48 | + * This method handles situations that requires to |
|
| 49 | + * select all from the table. |
|
| 50 | + * @param * |
|
| 51 | + */ |
|
| 52 | + public function all() |
|
| 53 | + { |
|
| 54 | + $this->queryBuilder = $this->queryBuilder->build("*"); |
|
| 55 | + return $this; |
|
| 56 | + } |
|
| 57 | + /** |
|
| 58 | + * {@inheritdoc} |
|
| 59 | + * |
|
| 60 | + * @param string $columns |
|
| 61 | + * |
|
| 62 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 63 | + */ |
|
| 64 | + public function columns(string ...$columns) |
|
| 65 | + { |
|
| 66 | + $this->queryBuilder = $this->queryBuilder->build(self::getImplodedString($columns)); |
|
| 67 | 67 | |
| 68 | - return $this; |
|
| 69 | - } |
|
| 68 | + return $this; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * {@inheritdoc} |
|
| 73 | - * |
|
| 74 | - * @param string $tableName |
|
| 75 | - * |
|
| 76 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 77 | - */ |
|
| 78 | - public function from(string $tableName) |
|
| 79 | - { |
|
| 80 | - $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName); |
|
| 71 | + /** |
|
| 72 | + * {@inheritdoc} |
|
| 73 | + * |
|
| 74 | + * @param string $tableName |
|
| 75 | + * |
|
| 76 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 77 | + */ |
|
| 78 | + public function from(string $tableName) |
|
| 79 | + { |
|
| 80 | + $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName); |
|
| 81 | 81 | |
| 82 | - return $this; |
|
| 83 | - } |
|
| 82 | + return $this; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * {@inheritdoc} |
|
| 87 | - * |
|
| 88 | - * @param string $tableName |
|
| 89 | - * @param string $condition |
|
| 90 | - * |
|
| 91 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 92 | - */ |
|
| 93 | - public function innerJoin(string $tableName, string $condition) |
|
| 94 | - { |
|
| 95 | - $string = "INNER JOIN ".$tableName." ON ".$condition; |
|
| 96 | - $this->queryBuilder = $this->queryBuilder->build($string); |
|
| 85 | + /** |
|
| 86 | + * {@inheritdoc} |
|
| 87 | + * |
|
| 88 | + * @param string $tableName |
|
| 89 | + * @param string $condition |
|
| 90 | + * |
|
| 91 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 92 | + */ |
|
| 93 | + public function innerJoin(string $tableName, string $condition) |
|
| 94 | + { |
|
| 95 | + $string = "INNER JOIN ".$tableName." ON ".$condition; |
|
| 96 | + $this->queryBuilder = $this->queryBuilder->build($string); |
|
| 97 | 97 | |
| 98 | - return $this; |
|
| 99 | - } |
|
| 98 | + return $this; |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -21,18 +21,18 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class UserIDValidator implements ValidatorInterface |
| 23 | 23 | { |
| 24 | - public function isValidUserId(string $userId) |
|
| 25 | - { |
|
| 26 | - $selectQuery = (new Builder('QueryBuilder', 'Select'))->getBuilder(); |
|
| 24 | + public function isValidUserId(string $userId) |
|
| 25 | + { |
|
| 26 | + $selectQuery = (new Builder('QueryBuilder', 'Select'))->getBuilder(); |
|
| 27 | 27 | |
| 28 | - $selectQuery |
|
| 29 | - ->top(1) |
|
| 30 | - ->columns('StaffID') |
|
| 31 | - ->from('[Staffs].[Staff]') |
|
| 32 | - ->where( |
|
| 33 | - 'StaffID', |
|
| 34 | - '='. |
|
| 35 | - $userId |
|
| 36 | - ); |
|
| 37 | - } |
|
| 28 | + $selectQuery |
|
| 29 | + ->top(1) |
|
| 30 | + ->columns('StaffID') |
|
| 31 | + ->from('[Staffs].[Staff]') |
|
| 32 | + ->where( |
|
| 33 | + 'StaffID', |
|
| 34 | + '='. |
|
| 35 | + $userId |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class UnexpectedErrorException extends Exception |
| 22 | 22 | { |
| 23 | - public function __construct(string $message, int $databaseUser) |
|
| 24 | - { |
|
| 25 | - parent::__construct($message, 0, $previous); |
|
| 23 | + public function __construct(string $message, int $databaseUser) |
|
| 24 | + { |
|
| 25 | + parent::__construct($message, 0, $previous); |
|
| 26 | 26 | |
| 27 | - $this->log($databaseUser, Constant::ERROR_401, Constant::ERROR_HIGH); |
|
| 28 | - } |
|
| 27 | + $this->log($databaseUser, Constant::ERROR_401, Constant::ERROR_HIGH); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class SQLException extends Exception |
| 22 | 22 | { |
| 23 | - public function __construct(string $message, int $databaseUser) |
|
| 24 | - { |
|
| 25 | - parent::__construct($message, 0, null); |
|
| 23 | + public function __construct(string $message, int $databaseUser) |
|
| 24 | + { |
|
| 25 | + parent::__construct($message, 0, null); |
|
| 26 | 26 | |
| 27 | - $this->log($databaseUser, Constant::ERROR_401, Constant::ERROR_NORMAL); |
|
| 28 | - } |
|
| 27 | + $this->log($databaseUser, Constant::ERROR_401, Constant::ERROR_NORMAL); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class UndefinedValueException extends Exception |
| 22 | 22 | { |
| 23 | - public function __construct(string $message, int $databaseUser) |
|
| 24 | - { |
|
| 25 | - parent::__construct($message, 0, null); |
|
| 23 | + public function __construct(string $message, int $databaseUser) |
|
| 24 | + { |
|
| 25 | + parent::__construct($message, 0, null); |
|
| 26 | 26 | |
| 27 | - $this->log($databaseUser, Constant::ERROR_404, Constant::ERROR_NORMAL); |
|
| 28 | - } |
|
| 27 | + $this->log($databaseUser, Constant::ERROR_404, Constant::ERROR_NORMAL); |
|
| 28 | + } |
|
| 29 | 29 | } |