Passed
Push — master ( 7498f0...d44413 )
by Adrian
01:44
created
src/Traits/TableValidation.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -45,22 +45,26 @@
 block discarded – undo
45 45
 	{
46 46
 		$table = trim( $table );
47 47
 
48
-		if ( '' === $table )
49
-			throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
48
+		if ( '' === $table ) {
49
+					throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
50
+		}
50 51
 
51
-		if ( DbConfig::getInstance()->useTablePrefix() )
52
-			$table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table );
52
+		if ( DbConfig::getInstance()->useTablePrefix() ) {
53
+					$table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table );
54
+		}
53 55
 
54 56
 		return $table;
55 57
 	}
56 58
 
57 59
 	private function validateTableSubQuery( $table )
58 60
 	{
59
-		if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT )
60
-			throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
61
+		if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) {
62
+					throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
63
+		}
61 64
 
62
-		if ( !is_a( $table, QuerySelect::class ) )
63
-			throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
65
+		if ( !is_a( $table, QuerySelect::class ) ) {
66
+					throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
67
+		}
64 68
 
65 69
 		return $table;
66 70
 	}
Please login to merge, or discard this patch.
src/Traits/Where.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @param string $glue
279 279
 	 * @return $this
280 280
 	 */
281
-	public function whereExpression( $whereString, array $bindParams = [], $glue = 'AND' )
281
+	public function whereExpression( $whereString, array $bindParams = [ ], $glue = 'AND' )
282 282
 	{
283 283
 		$whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams );
284 284
 		return $this->where( $whereString, $glue );
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @param array $bindParams
290 290
 	 * @return $this
291 291
 	 */
292
-	public function orWhereExpression( $whereString, array $bindParams = [] )
292
+	public function orWhereExpression( $whereString, array $bindParams = [ ] )
293 293
 	{
294 294
 		$whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams );
295 295
 		return $this->where( $whereString, 'OR' );
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 */
353 353
 	private function where( $param, $glue = 'AND' )
354 354
 	{
355
-		return $this->/** @scrutinizer ignore-call */ createCondition($param, $glue, QueryStructure::WHERE );
355
+		return $this->/** @scrutinizer ignore-call */ createCondition( $param, $glue, QueryStructure::WHERE );
356 356
 	}
357 357
 
358 358
 }
359 359
\ No newline at end of file
Please login to merge, or discard this patch.
src/DB/DbConnect.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -99,10 +99,10 @@
 block discarded – undo
99 99
 	 */
100 100
 	private function connect( $dataConnect )
101 101
 	{
102
-		$dsn = 'mysql:dbname=' . $dataConnect["dbname"] . ';host=' . $dataConnect["host"] . '';
102
+		$dsn = 'mysql:dbname=' . $dataConnect[ "dbname" ] . ';host=' . $dataConnect[ "host" ] . '';
103 103
 		try {
104 104
 
105
-			$pdo = new \PDO( $dsn, $dataConnect["user"], $dataConnect["password"],
105
+			$pdo = new \PDO( $dsn, $dataConnect[ "user" ], $dataConnect[ "password" ],
106 106
 				array( \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8" )
107 107
 			);
108 108
 
Please login to merge, or discard this patch.
src/DB/DbLog.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	public function writeQueryDuration( $query, $duration )
42 42
 	{
43 43
 		$backtrace = end( debug_backtrace() );
44
-		$location = $backtrace['file'] . " Line: " . $backtrace['line'];
44
+		$location = $backtrace[ 'file' ] . " Line: " . $backtrace[ 'line' ];
45 45
 
46 46
 		$this->path = DbConfig::getInstance()->getLogPathQueryDuration(); //my comments
47 47
 		$message = "Duration: " . round( $duration, 5 ) . "\r\n";
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
 	public function writeQueryErros( $query, $code, $error )
58 58
 	{
59 59
 		$backtrace = end( debug_backtrace() );
60
-		$location = $backtrace['file'] . " Line: " . $backtrace['line'];
60
+		$location = $backtrace[ 'file' ] . " Line: " . $backtrace[ 'line' ];
61 61
 
62 62
 		$this->path = DbConfig::getInstance()->getLogPathErrors(); //my comments
63 63
 		$message = "Query: $query" . "\r\n";
64 64
 		$message .= "Location: $location\r\n";
65 65
 		$message .= "Error code : " . $code . "\r\n";
66
-		$message .= "" . $error ;
66
+		$message .= "" . $error;
67 67
 
68 68
 		$this->write( $message );
69 69
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,12 +85,10 @@
 block discarded – undo
85 85
 				$fh = fopen( $log, 'a+' );
86 86
 				fwrite( $fh, $messageFormat );
87 87
 				fclose( $fh );
88
-			}
89
-			else {
88
+			} else {
90 89
 				$this->edit( $log, $messageFormat );
91 90
 			}
92
-		}
93
-		else {
91
+		} else {
94 92
 			if ( mkdir( $this->path, 0777 ) === true ) {
95 93
 				$this->write( $message );
96 94
 			}
Please login to merge, or discard this patch.
src/DB/DbService.php 2 patches
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	/**
44 44
 	 * @var array
45 45
 	 */
46
-	private $parameters = [];
46
+	private $parameters = [ ];
47 47
 
48 48
 
49 49
 	/**
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 
61 61
 		$this->queryInit( $query, $params );
62 62
 
63
-		if( $statement === self::QUERY_TYPE_SELECT ||
63
+		if ( $statement === self::QUERY_TYPE_SELECT ||
64 64
 			$statement === self::QUERY_TYPE_SHOW ||
65 65
 			$statement === self::QUERY_TYPE_DESC ||
66 66
 			$statement === self::QUERY_TYPE_EXPLAIN
67 67
 		) {
68 68
 			return $this->sQuery->fetchAll( $fetchMode );
69 69
 		}
70
-		elseif( $statement === self::QUERY_TYPE_INSERT ||
70
+		elseif ( $statement === self::QUERY_TYPE_INSERT ||
71 71
 			$statement === self::QUERY_TYPE_UPDATE ||
72 72
 			$statement === self::QUERY_TYPE_DELETE
73 73
 		) {
@@ -91,15 +91,15 @@  discard block
 block discarded – undo
91 91
 		$query = trim( str_replace( "\r", " ", $query ) );
92 92
 		$statement = self::getQueryStatement( $query );
93 93
 
94
-		if( $statement === self::QUERY_TYPE_EXPLAIN )
94
+		if ( $statement === self::QUERY_TYPE_EXPLAIN )
95 95
 			return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
96 96
 
97 97
 		$Columns = $this->sQuery->fetchAll( \PDO::FETCH_NUM );
98 98
 
99 99
 		$column = null;
100 100
 
101
-		foreach( $Columns as $cells ) {
102
-			$column[] = $cells[ 0 ];
101
+		foreach ( $Columns as $cells ) {
102
+			$column[ ] = $cells[ 0 ];
103 103
 		}
104 104
 
105 105
 		return $column;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		$query = trim( str_replace( "\r", " ", $query ) );
113 113
 		$statement = self::getQueryStatement( $query );
114 114
 
115
-		if( $statement === self::QUERY_TYPE_EXPLAIN )
115
+		if ( $statement === self::QUERY_TYPE_EXPLAIN )
116 116
 			return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
117 117
 
118 118
 		$result = $this->sQuery->fetch( $fetchmode );
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @param string $query
136 136
 	 * @param array $parameters
137 137
 	 */
138
-	private function queryInit( $query, $parameters = [] )
138
+	private function queryInit( $query, $parameters = [ ] )
139 139
 	{
140 140
 		$this->pdo = DbConnect::getInstance()->getConnection( self::getQueryStatement( $query ) );
141 141
 		$startQueryTime = microtime( true );
@@ -150,21 +150,21 @@  discard block
 block discarded – undo
150 150
 			/**
151 151
 			 * Add parameters to the parameter array
152 152
 			 */
153
-			if( self::isArrayAssoc( $parameters ) )
153
+			if ( self::isArrayAssoc( $parameters ) )
154 154
 				$this->bindMore( $parameters );
155 155
 			else
156
-				foreach( $parameters as $key => $val )
157
-					$this->parameters[] = array( $key + 1, $val );
156
+				foreach ( $parameters as $key => $val )
157
+					$this->parameters[ ] = array( $key + 1, $val );
158 158
 
159
-			if( count( $this->parameters ) ) {
160
-				foreach( $this->parameters as $param => $value ) {
161
-					if( is_int( $value[ 1 ] ) ) {
159
+			if ( count( $this->parameters ) ) {
160
+				foreach ( $this->parameters as $param => $value ) {
161
+					if ( is_int( $value[ 1 ] ) ) {
162 162
 						$type = \PDO::PARAM_INT;
163 163
 					}
164
-					elseif( is_bool( $value[ 1 ] ) ) {
164
+					elseif ( is_bool( $value[ 1 ] ) ) {
165 165
 						$type = \PDO::PARAM_BOOL;
166 166
 					}
167
-					elseif( is_null( $value[ 1 ] ) ) {
167
+					elseif ( is_null( $value[ 1 ] ) ) {
168 168
 						$type = \PDO::PARAM_NULL;
169 169
 					}
170 170
 					else {
@@ -176,13 +176,13 @@  discard block
 block discarded – undo
176 176
 
177 177
 			$this->sQuery->execute();
178 178
 
179
-			if( DbConfig::getInstance()->isEnableLogQueryDuration() ) {
179
+			if ( DbConfig::getInstance()->isEnableLogQueryDuration() ) {
180 180
 				$duration = microtime( true ) - $startQueryTime;
181 181
 				DbLog::getInstance()->writeQueryDuration( $query, $duration );
182 182
 			}
183 183
 
184
-		} catch( \PDOException $e ) {
185
-			if( DbConfig::getInstance()->isEnableLogErrors() ) {
184
+		} catch ( \PDOException $e ) {
185
+			if ( DbConfig::getInstance()->isEnableLogErrors() ) {
186 186
 				DbLog::getInstance()->writeQueryErros( $query, $e->getCode(), $e->getMessage() );
187 187
 			}
188 188
 			throw new DbException( 'Database error!', DbException::DB_QUERY_ERROR );
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
 	public function bindMore( $parray )
199 199
 	{
200
-		if( !count( $this->parameters ) && is_array( $parray ) ) {
200
+		if ( !count( $this->parameters ) && is_array( $parray ) ) {
201 201
 			$columns = array_keys( $parray );
202
-			foreach( $columns as $i => &$column ) {
202
+			foreach ( $columns as $i => &$column ) {
203 203
 				$this->bind( $column, $parray[ $column ] );
204 204
 			}
205 205
 		}
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 	{
226 226
 		$queryString = trim( $queryString );
227 227
 
228
-		if( $queryString === '' ) {
228
+		if ( $queryString === '' ) {
229 229
 			return self::QUERY_TYPE_EMPTY;
230 230
 		}
231 231
 
232
-		if( preg_match( '/^(select|insert|update|delete|replace|show|desc|explain)[\s]+/i', $queryString, $matches ) ) {
233
-			switch( strtolower( $matches[ 1 ] ) ) {
232
+		if ( preg_match( '/^(select|insert|update|delete|replace|show|desc|explain)[\s]+/i', $queryString, $matches ) ) {
233
+			switch ( strtolower( $matches[ 1 ] ) ) {
234 234
 				case 'select':
235 235
 					return self::QUERY_TYPE_SELECT;
236 236
 				case 'insert':
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 */
259 259
 	public static function isArrayAssoc( array $arr )
260 260
 	{
261
-		if( array() === $arr ) return false;
261
+		if ( array() === $arr ) return false;
262 262
 
263 263
 		return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
264 264
 	}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 */
270 270
 	public static function getInstance()
271 271
 	{
272
-		if( null === self::$instance ) {
272
+		if ( null === self::$instance ) {
273 273
 			self::$instance = new self();
274 274
 		}
275 275
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -21 removed lines patch added patch discarded remove patch
@@ -66,14 +66,12 @@  discard block
 block discarded – undo
66 66
 			$statement === self::QUERY_TYPE_EXPLAIN
67 67
 		) {
68 68
 			return $this->sQuery->fetchAll( $fetchMode );
69
-		}
70
-		elseif( $statement === self::QUERY_TYPE_INSERT ||
69
+		} elseif( $statement === self::QUERY_TYPE_INSERT ||
71 70
 			$statement === self::QUERY_TYPE_UPDATE ||
72 71
 			$statement === self::QUERY_TYPE_DELETE
73 72
 		) {
74 73
 			return $this->sQuery->rowCount();
75
-		}
76
-		else {
74
+		} else {
77 75
 
78 76
 			return NULL;
79 77
 		}
@@ -91,8 +89,9 @@  discard block
 block discarded – undo
91 89
 		$query = trim( str_replace( "\r", " ", $query ) );
92 90
 		$statement = self::getQueryStatement( $query );
93 91
 
94
-		if( $statement === self::QUERY_TYPE_EXPLAIN )
95
-			return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
92
+		if( $statement === self::QUERY_TYPE_EXPLAIN ) {
93
+					return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
94
+		}
96 95
 
97 96
 		$Columns = $this->sQuery->fetchAll( \PDO::FETCH_NUM );
98 97
 
@@ -112,8 +111,9 @@  discard block
 block discarded – undo
112 111
 		$query = trim( str_replace( "\r", " ", $query ) );
113 112
 		$statement = self::getQueryStatement( $query );
114 113
 
115
-		if( $statement === self::QUERY_TYPE_EXPLAIN )
116
-			return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
114
+		if( $statement === self::QUERY_TYPE_EXPLAIN ) {
115
+					return $this->sQuery->fetchAll( \PDO::FETCH_ASSOC );
116
+		}
117 117
 
118 118
 		$result = $this->sQuery->fetch( $fetchmode );
119 119
 		$this->sQuery->closeCursor(); // Frees up the connection to the server so that other SQL statements may be issued,
@@ -150,24 +150,22 @@  discard block
 block discarded – undo
150 150
 			/**
151 151
 			 * Add parameters to the parameter array
152 152
 			 */
153
-			if( self::isArrayAssoc( $parameters ) )
154
-				$this->bindMore( $parameters );
155
-			else
156
-				foreach( $parameters as $key => $val )
153
+			if( self::isArrayAssoc( $parameters ) ) {
154
+							$this->bindMore( $parameters );
155
+			} else {
156
+							foreach( $parameters as $key => $val )
157 157
 					$this->parameters[] = array( $key + 1, $val );
158
+			}
158 159
 
159 160
 			if( count( $this->parameters ) ) {
160 161
 				foreach( $this->parameters as $param => $value ) {
161 162
 					if( is_int( $value[ 1 ] ) ) {
162 163
 						$type = \PDO::PARAM_INT;
163
-					}
164
-					elseif( is_bool( $value[ 1 ] ) ) {
164
+					} elseif( is_bool( $value[ 1 ] ) ) {
165 165
 						$type = \PDO::PARAM_BOOL;
166
-					}
167
-					elseif( is_null( $value[ 1 ] ) ) {
166
+					} elseif( is_null( $value[ 1 ] ) ) {
168 167
 						$type = \PDO::PARAM_NULL;
169
-					}
170
-					else {
168
+					} else {
171 169
 						$type = \PDO::PARAM_STR;
172 170
 					}
173 171
 					$this->sQuery->bindValue( $value[ 0 ], $value[ 1 ], $type );
@@ -246,8 +244,7 @@  discard block
 block discarded – undo
246 244
 				default:
247 245
 					return self::QUERY_TYPE_OTHER;
248 246
 			}
249
-		}
250
-		else {
247
+		} else {
251 248
 			return self::QUERY_TYPE_OTHER;
252 249
 		}
253 250
 	}
@@ -258,7 +255,9 @@  discard block
 block discarded – undo
258 255
 	 */
259 256
 	public static function isArrayAssoc( array $arr )
260 257
 	{
261
-		if( array() === $arr ) return false;
258
+		if( array() === $arr ) {
259
+			return false;
260
+		}
262 261
 
263 262
 		return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
264 263
 	}
Please login to merge, or discard this patch.
src/Statements/QueryUpdate.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,47 +52,47 @@
 block discarded – undo
52 52
 		/**
53 53
 		 *  Explain
54 54
 		 */
55
-		$syntax[] = $this->getExplainSyntax();
55
+		$syntax[ ] = $this->getExplainSyntax();
56 56
 
57 57
 		/**
58 58
 		 * UPDATE statement
59 59
 		 */
60
-		$syntax[] = $this->statement;
60
+		$syntax[ ] = $this->statement;
61 61
 
62 62
 		/**
63 63
 		 * PRIORITY
64 64
 		 */
65
-		$syntax[] = $this->queryStructure->getElement( QueryStructure::PRIORITY );
65
+		$syntax[ ] = $this->queryStructure->getElement( QueryStructure::PRIORITY );
66 66
 
67 67
 		/**
68 68
 		 * IGNORE clause
69 69
 		 */
70
-		$syntax[] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : '';
70
+		$syntax[ ] = $this->queryStructure->getElement( QueryStructure::IGNORE ) ? 'IGNORE' : '';
71 71
 
72 72
 		/**
73 73
 		 * TABLE update
74 74
 		 */
75
-		$syntax[] = $this->queryStructure->getElement( QueryStructure::TABLE );
75
+		$syntax[ ] = $this->queryStructure->getElement( QueryStructure::TABLE );
76 76
 
77 77
 		/**
78 78
 		 * FIELDS update
79 79
 		 */
80
-		$syntax[] = $this->getSettingFieldsSyntax();
80
+		$syntax[ ] = $this->getSettingFieldsSyntax();
81 81
 
82 82
 		/**
83 83
 		 * WHERE clause
84 84
 		 */
85
-		$syntax[] = $this->getWhereSyntax();
85
+		$syntax[ ] = $this->getWhereSyntax();
86 86
 
87 87
 		/**
88 88
 		 * ORDER BY clause
89 89
 		 */
90
-		$syntax[] = $this->getOrderBySyntax();
90
+		$syntax[ ] = $this->getOrderBySyntax();
91 91
 
92 92
 		/**
93 93
 		 * LIMIT clause
94 94
 		 */
95
-		$syntax[] = $this->getLimitSyntax();
95
+		$syntax[ ] = $this->getLimitSyntax();
96 96
 
97 97
 		$syntax = implode( ' ', $syntax );
98 98
 
Please login to merge, or discard this patch.