Passed
Push — master ( c939c5...988421 )
by Adrian
02:18
created
src/Traits/TableValidation.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,22 +44,26 @@
 block discarded – undo
44 44
 	{
45 45
 		$table = trim( $table );
46 46
 
47
-		if ( '' === $table )
48
-			throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
47
+		if ( '' === $table ) {
48
+					throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
49
+		}
49 50
 
50
-		if ( DbConfig::getInstance()->useTablePrefix() )
51
-			$table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table );
51
+		if ( DbConfig::getInstance()->useTablePrefix() ) {
52
+					$table = str_ireplace( '::', DbConfig::getInstance()->getTablePrefix(), $table );
53
+		}
52 54
 
53 55
 		return $table;
54 56
 	}
55 57
 
56 58
 	private function validateTableSubQuery( $table )
57 59
 	{
58
-		if ( $this->statement !== self::QUERY_STATEMENT_SELECT )
59
-			throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
60
+		if ( $this->statement !== self::QUERY_STATEMENT_SELECT ) {
61
+					throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
62
+		}
60 63
 
61
-		if ( !is_a( $table, QuerySelect::class ) )
62
-			throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
64
+		if ( !is_a( $table, QuerySelect::class ) ) {
65
+					throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
66
+		}
63 67
 
64 68
 		return $table;
65 69
 	}
Please login to merge, or discard this patch.
src/Traits/GroupBy.php 1 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 GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
31
+		if ( !$this->validateColumn( $column, $allowedColumns ) ) {
32
+					throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
33
+		}
33 34
 
34 35
 		$this->queryStructure->setElement( QueryStructure::GROUP_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 GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
51
+		if ( !$this->validateColumn( $column, $allowedColumns ) ) {
52
+					throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
53
+		}
52 54
 
53 55
 		$this->queryStructure->setElement( QueryStructure::GROUP_BY, $column . ' DESC' );
54 56
 
@@ -73,8 +75,9 @@  discard block
 block discarded – undo
73 75
 	 */
74 76
 	private function getGroupBySyntax()
75 77
 	{
76
-		if ( count( $this->queryStructure->getElement( QueryStructure::GROUP_BY ) ) )
77
-			return 'GROUP BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::GROUP_BY ), ', ' );
78
+		if ( count( $this->queryStructure->getElement( QueryStructure::GROUP_BY ) ) ) {
79
+					return 'GROUP BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::GROUP_BY ), ', ' );
80
+		}
78 81
 
79 82
 		return '';
80 83
 	}
Please login to merge, or discard this patch.
src/Dependencies/QueryHelper.php 1 patch
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -87,7 +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 ) $newArray[] = $value;
90
+			if ( '' !== $value ) {
91
+				$newArray[] = $value;
92
+			}
91 93
 		}
92 94
 
93 95
 		return $newArray;
@@ -137,8 +139,9 @@  discard block
 block discarded – undo
137 139
 		$characters = 'abcdefghijklmnopqrstuvwxyz';
138 140
 		$charactersLength = strlen( $characters );
139 141
 		$randomString = '';
140
-		for ( $i = 0; $i < $length; $i++ )
141
-			$randomString .= $characters[ rand( 0, $charactersLength - 1 ) ];
142
+		for ( $i = 0; $i < $length; $i++ ) {
143
+					$randomString .= $characters[ rand( 0, $charactersLength - 1 ) ];
144
+		}
142 145
 
143 146
 		return str_shuffle( $randomString );
144 147
 	}
@@ -146,8 +149,9 @@  discard block
 block discarded – undo
146 149
 	public static function limitString( $rowCount, $offset = null )
147 150
 	{
148 151
 		$rowCount = intval( $rowCount );
149
-		if ( is_null( $offset ) )
150
-			return $rowCount;
152
+		if ( is_null( $offset ) ) {
153
+					return $rowCount;
154
+		}
151 155
 		$offset = intval( $offset );
152 156
 
153 157
 		return "$offset, $rowCount";
Please login to merge, or discard this patch.
src/Dependencies/QueryStructure.php 1 patch
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.
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+' ) or die( "Fatal Error !" );
86 86
 				fwrite( $fh, $messageFormat );
87 87
 				fclose( $fh );
88
-			}
89
-			else {
88
+			} else {
90 89
 				$this->edit( $log, $date, $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/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/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/Statements/QueryUpdate.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -110,8 +110,9 @@
 block discarded – undo
110 110
 		if (
111 111
 			$this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) &&
112 112
 			!count( $this->queryStructure->getElement( QueryStructure::WHERE ) )
113
-		)
114
-			throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER );
113
+		) {
114
+					throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER );
115
+		}
115 116
 
116 117
 		return DbService::getInstance()->query(
117 118
 			$this->getSyntax(),
Please login to merge, or discard this patch.
src/Statements/QuerySelect.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@  discard block
 block discarded – undo
55 55
 			$this->queryStructure->setElement( QueryStructure::TABLE, $tableName );
56 56
 
57 57
 			$tableSelectParams = $table->getBindParams();
58
-			foreach ( $tableSelectParams as $key => $value )
59
-				$this->queryStructure->setParams( $key, $value );
58
+			foreach ( $tableSelectParams as $key => $value ) {
59
+							$this->queryStructure->setParams( $key, $value );
60
+			}
60 61
 
61 62
 		}
62 63
 	}
@@ -107,8 +108,9 @@  discard block
 block discarded – undo
107 108
 			$this->queryStructure->setElement( QueryStructure::DISTINCT, 0 ); //???
108 109
 		}
109 110
 
110
-		if ( $this->queryStructure->getElement( QueryStructure::FIRST ) )
111
-			$this->queryStructure->setElement( QueryStructure::LIMIT, 1 );
111
+		if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) {
112
+					$this->queryStructure->setElement( QueryStructure::LIMIT, 1 );
113
+		}
112 114
 
113 115
 		$syntax = array();
114 116
 
@@ -190,8 +192,9 @@  discard block
 block discarded – undo
190 192
 				return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) );
191 193
 				break;
192 194
 			case $this->queryStructure->getElement( QueryStructure::FIRST ):
193
-				if ( $this->queryStructure->getElement( QueryStructure::COLUMN ) )
194
-					return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) );
195
+				if ( $this->queryStructure->getElement( QueryStructure::COLUMN ) ) {
196
+									return DbService::getInstance()->single( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) );
197
+				}
195 198
 
196 199
 				return DbService::getInstance()->row( $this->getSyntax(), $this->queryStructure->getElement( QueryStructure::BIND_PARAMS ) );
197 200
 				break;
Please login to merge, or discard this patch.