Passed
Push — master ( 7ff405...d0230e )
by Adrian
01:39
created
src/Dependencies/QueryStructure.php 2 patches
Braces   +23 added lines, -16 removed lines patch added patch discarded remove patch
@@ -85,8 +85,9 @@  discard block
 block discarded – undo
85 85
 	{
86 86
 		$this->syntaxEL = $this->init();
87 87
 
88
-		foreach ( $this->syntaxEL as $name => $value )
89
-			$this->typeEL[ $name ] = gettype( $value );
88
+		foreach ( $this->syntaxEL as $name => $value ) {
89
+					$this->typeEL[ $name ] = gettype( $value );
90
+		}
90 91
 
91 92
 	}
92 93
 
@@ -172,16 +173,19 @@  discard block
 block discarded – undo
172 173
 	 */
173 174
 	public function setElement( $name, $value )
174 175
 	{
175
-		if ( !array_key_exists( $name, $this->syntaxEL ) )
176
-			throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND );
176
+		if ( !array_key_exists( $name, $this->syntaxEL ) ) {
177
+					throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND );
178
+		}
177 179
 
178
-		if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) )
179
-			return true;
180
+		if ( $name == self::TABLE && is_a( $value, QueryStatement::class ) ) {
181
+					return true;
182
+		}
180 183
 
181
-		if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY )
182
-			$this->syntaxEL[ $name ][] = $value;
183
-		else
184
-			$this->syntaxEL[ $name ] = $value;
184
+		if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY ) {
185
+					$this->syntaxEL[ $name ][] = $value;
186
+		} else {
187
+					$this->syntaxEL[ $name ] = $value;
188
+		}
185 189
 
186 190
 		return true;
187 191
 	}
@@ -194,8 +198,9 @@  discard block
 block discarded – undo
194 198
 	 */
195 199
 	public function replaceElement( $elementName, $elementValue )
196 200
 	{
197
-		if ( !array_key_exists( $elementName, $this->syntaxEL ) )
198
-			throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND );
201
+		if ( !array_key_exists( $elementName, $this->syntaxEL ) ) {
202
+					throw new QueryException( 'Invalid Query property', QueryException::QUERY_ERROR_ELEMENT_NOT_FOUND );
203
+		}
199 204
 
200 205
 		$this->syntaxEL[ $elementName ] = $elementValue;
201 206
 	}
@@ -243,11 +248,13 @@  discard block
 block discarded – undo
243 248
 	 */
244 249
 	public function bindParamsExpression( $expression, array $params = [], $search = '?' )
245 250
 	{
246
-		if ( !count( $params ) )
247
-			return $expression;
251
+		if ( !count( $params ) ) {
252
+					return $expression;
253
+		}
248 254
 
249
-		if ( strpos( $expression, $search ) === false )
250
-			return $expression;
255
+		if ( strpos( $expression, $search ) === false ) {
256
+					return $expression;
257
+		}
251 258
 
252 259
 		$params = array_slice( $params, 0, substr_count( $expression, $search ) );
253 260
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * @var array
62 62
 	 */
63
-	private static $usedInstanceIds = [];
63
+	private static $usedInstanceIds = [ ];
64 64
 
65 65
 	/**
66 66
 	 * @var array
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		while ( in_array( $instance, self::$usedInstanceIds ) ) {
133 133
 			$instance = QueryHelper::random( 7 );
134 134
 		}
135
-		self::$usedInstanceIds[] = $instance;
135
+		self::$usedInstanceIds[ ] = $instance;
136 136
 
137 137
 		return $instance;
138 138
 	}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			return true;
180 180
 
181 181
 		if ( $this->typeEL[ $name ] === self::ELEMENT_TYPE_ARRAY )
182
-			$this->syntaxEL[ $name ][] = $value;
182
+			$this->syntaxEL[ $name ][ ] = $value;
183 183
 		else
184 184
 			$this->syntaxEL[ $name ] = $value;
185 185
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @param string $search
242 242
 	 * @return string
243 243
 	 */
244
-	public function bindParamsExpression( $expression, array $params = [], $search = '?' )
244
+	public function bindParamsExpression( $expression, array $params = [ ], $search = '?' )
245 245
 	{
246 246
 		if ( !count( $params ) )
247 247
 			return $expression;
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 		$params = array_slice( $params, 0, substr_count( $expression, $search ) );
253 253
 
254 254
 		$i = 0;
255
-		$arrayReturn = [];
255
+		$arrayReturn = [ ];
256 256
 		$expressionToArray = explode( $search, $expression );
257 257
 
258 258
 		foreach ( $expressionToArray as $sub ) {
259
-			$arrayReturn[] = $sub;
260
-			$arrayReturn[] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : '';
259
+			$arrayReturn[ ] = $sub;
260
+			$arrayReturn[ ] = array_key_exists( $i, $params ) ? $this->bindParam( 'exp', $params[ $i ] ) : '';
261 261
 			$i++;
262 262
 		}
263 263
 
Please login to merge, or discard this patch.
src/DB/DbConnect.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,8 +42,9 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function getMasterConnection()
44 44
 	{
45
-		if ( !is_a( $this->pdoMaster, \PDO::class ) )
46
-			$this->pdoMaster = $this->connect( $this->config->getMasterDataConnect() );
45
+		if ( !is_a( $this->pdoMaster, \PDO::class ) ) {
46
+					$this->pdoMaster = $this->connect( $this->config->getMasterDataConnect() );
47
+		}
47 48
 
48 49
 		return $this->pdoMaster;
49 50
 	}
@@ -53,11 +54,13 @@  discard block
 block discarded – undo
53 54
 	 */
54 55
 	public function getSlaveConnection()
55 56
 	{
56
-		if ( !$this->config->getReplicationEnable() )
57
-			return $this->getMasterConnection();
57
+		if ( !$this->config->getReplicationEnable() ) {
58
+					return $this->getMasterConnection();
59
+		}
58 60
 
59
-		if ( !is_a( $this->pdoSlave, \PDO::class ) )
60
-			$this->pdoSlave = $this->connect( $this->config->getSlaveDataConnect() );
61
+		if ( !is_a( $this->pdoSlave, \PDO::class ) ) {
62
+					$this->pdoSlave = $this->connect( $this->config->getSlaveDataConnect() );
63
+		}
61 64
 
62 65
 		return $this->pdoSlave;
63 66
 	}
@@ -70,8 +73,9 @@  discard block
 block discarded – undo
70 73
 	{
71 74
 		$statement = trim( strtolower( $statement ) );
72 75
 
73
-		if ( $statement === DbService::QUERY_TYPE_SELECT )
74
-			return $this->getSlaveConnection();
76
+		if ( $statement === DbService::QUERY_TYPE_SELECT ) {
77
+					return $this->getSlaveConnection();
78
+		}
75 79
 
76 80
 		return $this->getMasterConnection();
77 81
 	}
Please login to merge, or discard this patch.
src/DB/DbLog.php 1 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/DbConfig.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -60,10 +60,11 @@  discard block
 block discarded – undo
60 60
 	private function __construct()
61 61
 	{
62 62
 		$vendorCfg = __DIR__ . '/../../../../../vendor-cfg/qpdb_db_config.php';
63
-		if ( file_exists( $vendorCfg ) )
64
-			$this->dbConfig = require $vendorCfg;
65
-		else
66
-			$this->dbConfig = require __DIR__ . '/../../config/qpdb_db_config.php';
63
+		if ( file_exists( $vendorCfg ) ) {
64
+					$this->dbConfig = require $vendorCfg;
65
+		} else {
66
+					$this->dbConfig = require __DIR__ . '/../../config/qpdb_db_config.php';
67
+		}
67 68
 
68 69
 		$this->buildConfig();
69 70
 	}
@@ -146,8 +147,9 @@  discard block
 block discarded – undo
146 147
 
147 148
 	public function useTablePrefix()
148 149
 	{
149
-		if ( !empty( $this->dbConfig[ 'use_table_prefix' ] ) )
150
-			return $this->dbConfig[ 'use_table_prefix' ];
150
+		if ( !empty( $this->dbConfig[ 'use_table_prefix' ] ) ) {
151
+					return $this->dbConfig[ 'use_table_prefix' ];
152
+		}
151 153
 
152 154
 		return false;
153 155
 	}
@@ -182,8 +184,9 @@  discard block
 block discarded – undo
182 184
 	private function readMasterDataConnect()
183 185
 	{
184 186
 
185
-		if ( !isset( $this->dbConfig[ 'master_data_connect' ][ 0 ] ) )
186
-			throw new DbException( 'Master data connect is missing', DbException::DB_ERROR_MASTER_DATA_CONNECTION_MISSING );
187
+		if ( !isset( $this->dbConfig[ 'master_data_connect' ][ 0 ] ) ) {
188
+					throw new DbException( 'Master data connect is missing', DbException::DB_ERROR_MASTER_DATA_CONNECTION_MISSING );
189
+		}
187 190
 
188 191
 		$dataConnection = $this->dbConfig[ 'master_data_connect' ];
189 192
 
Please login to merge, or discard this patch.
src/DB/DbService.php 2 patches
Spacing   +4 added lines, -4 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
 	/**
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		$column = null;
100 100
 
101 101
 		foreach ( $Columns as $cells ) {
102
-			$column[] = $cells[ 0 ];
102
+			$column[ ] = $cells[ 0 ];
103 103
 		}
104 104
 
105 105
 		return $column;
@@ -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 );
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 				$this->bindMore( $parameters );
155 155
 			else
156 156
 				foreach ( $parameters as $key => $val )
157
-					$this->parameters[] = array( $key + 1, $val );
157
+					$this->parameters[ ] = array( $key + 1, $val );
158 158
 
159 159
 			if ( count( $this->parameters ) ) {
160 160
 				foreach ( $this->parameters as $param => $value ) {
Please login to merge, or discard this patch.
Braces   +20 added lines, -22 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,8 +255,9 @@  discard block
 block discarded – undo
258 255
 	 */
259 256
 	public static function isArrayAssoc( array $arr )
260 257
 	{
261
-		if ( array() === $arr )
262
-			return false;
258
+		if ( array() === $arr ) {
259
+					return false;
260
+		}
263 261
 
264 262
 		return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
265 263
 	}
Please login to merge, or discard this patch.
src/Dependencies/QueryHelper.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@
 block discarded – undo
88 88
 		foreach ( $brutArray as $value ) {
89 89
 			$value = trim( $value );
90 90
 			if ( '' !== $value )
91
-				$newArray[] = $value;
91
+				$newArray[ ] = $value;
92 92
 		}
93 93
 
94 94
 		return $newArray;
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 		$newArray = array();
88 88
 		foreach ( $brutArray as $value ) {
89 89
 			$value = trim( $value );
90
-			if ( '' !== $value )
91
-				$newArray[] = $value;
90
+			if ( '' !== $value ) {
91
+							$newArray[] = $value;
92
+			}
92 93
 		}
93 94
 
94 95
 		return $newArray;
@@ -138,8 +139,9 @@  discard block
 block discarded – undo
138 139
 		$characters = 'abcdefghijklmnopqrstuvwxyz';
139 140
 		$charactersLength = strlen( $characters );
140 141
 		$randomString = '';
141
-		for ( $i = 0; $i < $length; $i++ )
142
-			$randomString .= $characters[ rand( 0, $charactersLength - 1 ) ];
142
+		for ( $i = 0; $i < $length; $i++ ) {
143
+					$randomString .= $characters[ rand( 0, $charactersLength - 1 ) ];
144
+		}
143 145
 
144 146
 		return str_shuffle( $randomString );
145 147
 	}
@@ -147,8 +149,9 @@  discard block
 block discarded – undo
147 149
 	public static function limitString( $rowCount, $offset = null )
148 150
 	{
149 151
 		$rowCount = intval( $rowCount );
150
-		if ( is_null( $offset ) )
151
-			return $rowCount;
152
+		if ( is_null( $offset ) ) {
153
+					return $rowCount;
154
+		}
152 155
 		$offset = intval( $offset );
153 156
 
154 157
 		return "$offset, $rowCount";
Please login to merge, or discard this patch.
src/Traits/Where.php 1 patch
Spacing   +2 added lines, -2 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
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @param array $bindParams
291 291
 	 * @return $this
292 292
 	 */
293
-	public function orWhereExpression( $whereString, array $bindParams = [] )
293
+	public function orWhereExpression( $whereString, array $bindParams = [ ] )
294 294
 	{
295 295
 		$whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams );
296 296
 
Please login to merge, or discard this patch.
src/Traits/OrderBy.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @return $this
25 25
 	 * @throws QueryException
26 26
 	 */
27
-	public function orderBy( $column, array $allowedColumns = [] )
27
+	public function orderBy( $column, array $allowedColumns = [ ] )
28 28
 	{
29 29
 		$column = trim( $column );
30 30
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @return $this
44 44
 	 * @throws QueryException
45 45
 	 */
46
-	public function orderByDesc( $column, array $allowedColumns = [] )
46
+	public function orderByDesc( $column, array $allowedColumns = [ ] )
47 47
 	{
48 48
 		$column = trim( $column );
49 49
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
 	{
29 29
 		$column = trim( $column );
30 30
 
31
-		if ( !$this->validateColumn( $column, $allowedColumns ) )
32
-			throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
31
+		if ( !$this->validateColumn( $column, $allowedColumns ) ) {
32
+					throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
33
+		}
33 34
 
34 35
 		$this->queryStructure->setElement( QueryStructure::ORDER_BY, $column );
35 36
 
@@ -47,8 +48,9 @@  discard block
 block discarded – undo
47 48
 	{
48 49
 		$column = trim( $column );
49 50
 
50
-		if ( !$this->validateColumn( $column, $allowedColumns ) )
51
-			throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
51
+		if ( !$this->validateColumn( $column, $allowedColumns ) ) {
52
+					throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
53
+		}
52 54
 
53 55
 		$this->queryStructure->setElement( QueryStructure::ORDER_BY, $column . ' DESC' );
54 56
 
@@ -73,8 +75,9 @@  discard block
 block discarded – undo
73 75
 	 */
74 76
 	private function getOrderBySyntax()
75 77
 	{
76
-		if ( count( $this->queryStructure->getElement( QueryStructure::ORDER_BY ) ) )
77
-			return 'ORDER BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::ORDER_BY ), ', ' );
78
+		if ( count( $this->queryStructure->getElement( QueryStructure::ORDER_BY ) ) ) {
79
+					return 'ORDER BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::ORDER_BY ), ', ' );
80
+		}
78 81
 
79 82
 		return '';
80 83
 	}
Please login to merge, or discard this patch.
src/Traits/Having.php 1 patch
Spacing   +2 added lines, -2 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 havingExpression( $whereString, array $bindParams = [], $glue = 'AND' )
281
+	public function havingExpression( $whereString, array $bindParams = [ ], $glue = 'AND' )
282 282
 	{
283 283
 		$whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams );
284 284
 
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @param array $bindParams
291 291
 	 * @return $this
292 292
 	 */
293
-	public function orHavingExpression( $whereString, array $bindParams = [] )
293
+	public function orHavingExpression( $whereString, array $bindParams = [ ] )
294 294
 	{
295 295
 		$whereString = $this->queryStructure->bindParamsExpression( $whereString, $bindParams );
296 296
 
Please login to merge, or discard this patch.