Passed
Push — master ( 7498f0...d44413 )
by Adrian
01:44
created
src/Traits/Join.php 1 patch
Braces   +5 added lines, -4 removed lines patch added patch discarded remove patch
@@ -116,10 +116,11 @@
 block discarded – undo
116 116
 	{
117 117
 		$join = $typeJoin . ' ' . $tableJoin;
118 118
 
119
-		if ( is_null( $onRight ) )
120
-			$join .= " USING ( $onLeft )";
121
-		else
122
-			$join .= " ON $onLeft = $onRight";
119
+		if ( is_null( $onRight ) ) {
120
+					$join .= " USING ( $onLeft )";
121
+		} else {
122
+					$join .= " ON $onLeft = $onRight";
123
+		}
123 124
 
124 125
 		$this->queryStructure->setElement( QueryStructure::JOIN, $join );
125 126
 
Please login to merge, or discard this patch.
src/Traits/Limit.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -28,11 +28,13 @@  discard block
 block discarded – undo
28 28
 	{
29 29
 		$limit = trim( $limit );
30 30
 
31
-		if ( !QueryHelper::isInteger( $limit ) )
32
-			throw new QueryException( 'Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT );
31
+		if ( !QueryHelper::isInteger( $limit ) ) {
32
+					throw new QueryException( 'Invalid Limit value', QueryException::QUERY_ERROR_INVALID_LIMIT );
33
+		}
33 34
 
34
-		if ( $limit == 0 )
35
-			throw new QueryException( 'Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO );
35
+		if ( $limit == 0 ) {
36
+					throw new QueryException( 'Invalid Limit zero', QueryException::QUERY_ERROR_INVALID_LIMIT_ZERO );
37
+		}
36 38
 
37 39
 		if ( is_null( $offset ) ) {
38 40
 			$this->queryStructure->setElement( QueryStructure::LIMIT, $limit );
@@ -42,8 +44,9 @@  discard block
 block discarded – undo
42 44
 
43 45
 		$offset = trim( $offset );
44 46
 
45
-		if ( !QueryHelper::isInteger( $offset ) )
46
-			throw new QueryException( 'Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET );
47
+		if ( !QueryHelper::isInteger( $offset ) ) {
48
+					throw new QueryException( 'Invalid Limit offset', QueryException::QUERY_ERROR_INVALID_LIMIT_OFFSET );
49
+		}
47 50
 
48 51
 		$this->queryStructure->setElement( QueryStructure::LIMIT, $offset . ',' . $limit );
49 52
 
@@ -52,8 +55,9 @@  discard block
 block discarded – undo
52 55
 
53 56
 	private function getLimitSyntax()
54 57
 	{
55
-		if ( !$this->queryStructure->getElement( QueryStructure::LIMIT ) )
56
-			return '';
58
+		if ( !$this->queryStructure->getElement( QueryStructure::LIMIT ) ) {
59
+					return '';
60
+		}
57 61
 
58 62
 		return 'LIMIT ' . $this->queryStructure->getElement( QueryStructure::LIMIT );
59 63
 	}
Please login to merge, or discard this patch.
src/Traits/Utilities.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@
 block discarded – undo
28 28
 
29 29
 	protected function getExplainSyntax()
30 30
 	{
31
-		if($this->queryStructure->getElement(QueryStructure::EXPLAIN))
32
-			return 'EXPLAIN';
31
+		if($this->queryStructure->getElement(QueryStructure::EXPLAIN)) {
32
+					return 'EXPLAIN';
33
+		}
33 34
 
34 35
 		return '';
35 36
 	}
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,14 +21,14 @@
 block discarded – undo
21 21
 	 */
22 22
 	public function explain()
23 23
 	{
24
-		$this->queryStructure->setElement(QueryStructure::EXPLAIN, 1);
24
+		$this->queryStructure->setElement( QueryStructure::EXPLAIN, 1 );
25 25
 
26 26
 		return $this;
27 27
 	}
28 28
 
29 29
 	protected function getExplainSyntax()
30 30
 	{
31
-		if($this->queryStructure->getElement(QueryStructure::EXPLAIN))
31
+		if ( $this->queryStructure->getElement( QueryStructure::EXPLAIN ) )
32 32
 			return 'EXPLAIN';
33 33
 
34 34
 		return '';
Please login to merge, or discard this patch.
src/Traits/ColumnValidation.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -16,11 +16,13 @@
 block discarded – undo
16 16
 
17 17
 	protected function validateColumn( $columnName, array $allowed )
18 18
 	{
19
-		if ( is_integer( $columnName ) )
20
-			return true;
19
+		if ( is_integer( $columnName ) ) {
20
+					return true;
21
+		}
21 22
 
22
-		if ( !count( $allowed ) )
23
-			return true;
23
+		if ( !count( $allowed ) ) {
24
+					return true;
25
+		}
24 26
 
25 27
 		return false;
26 28
 	}
Please login to merge, or discard this patch.
src/Traits/Replacement.php 2 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,9 @@
 block discarded – undo
27 27
 	{
28 28
 		$syntax = QueryHelper::clearMultipleSpaces( $syntax );
29 29
 
30
-		if ( !$withReplacement )
31
-			return $syntax;
30
+		if ( !$withReplacement ) {
31
+					return $syntax;
32
+		}
32 33
 
33 34
 		return $this->replaceValues( $syntax );
34 35
 	}
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,8 +43,8 @@
 block discarded – undo
43 43
 		$search = array();
44 44
 		$replace = array();
45 45
 		foreach ( $bindParams as $key => $value ) {
46
-			$search[] = ':' . $key;
47
-			$replace[] = DbConnect::getInstance()->quote( $value );
46
+			$search[ ] = ':' . $key;
47
+			$replace[ ] = DbConnect::getInstance()->quote( $value );
48 48
 		}
49 49
 		$syntax = str_ireplace( $search, $replace, $syntax );
50 50
 
Please login to merge, or discard this patch.
src/Traits/SelectFields.php 2 patches
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,19 +30,21 @@  discard block
 block discarded – undo
30 30
 
31 31
 				$fields = $this->prepareArrayFields( $fields );
32 32
 
33
-				if ( count( $fields ) )
34
-					$this->queryStructure->setElement( QueryStructure::FIELDS, implode( ', ', $fields ) );
35
-				else
36
-					$this->queryStructure->setElement( QueryStructure::FIELDS, '*' );
33
+				if ( count( $fields ) ) {
34
+									$this->queryStructure->setElement( QueryStructure::FIELDS, implode( ', ', $fields ) );
35
+				} else {
36
+									$this->queryStructure->setElement( QueryStructure::FIELDS, '*' );
37
+				}
37 38
 				break;
38 39
 
39 40
 			case QueryStructure::ELEMENT_TYPE_STRING:
40 41
 
41 42
 				$fields = trim( $fields );
42
-				if ( '' !== $fields )
43
-					$this->queryStructure->setElement( QueryStructure::FIELDS, $fields );
44
-				else
45
-					$this->queryStructure->setElement( QueryStructure::FIELDS, '*' );
43
+				if ( '' !== $fields ) {
44
+									$this->queryStructure->setElement( QueryStructure::FIELDS, $fields );
45
+				} else {
46
+									$this->queryStructure->setElement( QueryStructure::FIELDS, '*' );
47
+				}
46 48
 				break;
47 49
 
48 50
 			default:
@@ -63,11 +65,13 @@  discard block
 block discarded – undo
63 65
 		$prepareArray = [];
64 66
 
65 67
 		foreach ( $fieldsArray as $field ) {
66
-			if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING )
67
-				throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD );
68
+			if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING ) {
69
+							throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD );
70
+			}
68 71
 
69
-			if ( '' !== trim( $field ) )
70
-				$prepareArray[] = trim( $field );
72
+			if ( '' !== trim( $field ) ) {
73
+							$prepareArray[] = trim( $field );
74
+			}
71 75
 		}
72 76
 
73 77
 		return $prepareArray;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,14 +60,14 @@
 block discarded – undo
60 60
 	 */
61 61
 	private function prepareArrayFields( $fieldsArray = array() )
62 62
 	{
63
-		$prepareArray = [];
63
+		$prepareArray = [ ];
64 64
 
65 65
 		foreach ( $fieldsArray as $field ) {
66 66
 			if ( gettype( $field ) !== QueryStructure::ELEMENT_TYPE_STRING )
67 67
 				throw new QueryException( 'Invalid select field type!', QueryException::QUERY_ERROR_SELECT_INVALID_FIELD );
68 68
 
69 69
 			if ( '' !== trim( $field ) )
70
-				$prepareArray[] = trim( $field );
70
+				$prepareArray[ ] = trim( $field );
71 71
 		}
72 72
 
73 73
 		return $prepareArray;
Please login to merge, or discard this patch.
src/Traits/InsertMultiple.php 2 patches
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,8 +29,9 @@  discard block
 block discarded – undo
29 29
 	{
30 30
 		$this->setFieldsList( $fieldsList );
31 31
 
32
-		foreach ( $rowsForInsert as $row )
33
-			$this->addSingleRow( $row );
32
+		foreach ( $rowsForInsert as $row ) {
33
+					$this->addSingleRow( $row );
34
+		}
34 35
 
35 36
 		return $this;
36 37
 	}
@@ -45,8 +46,9 @@  discard block
 block discarded – undo
45 46
 	{
46 47
 		$this->setFieldsList( $fieldsList );
47 48
 
48
-		foreach ( $query->getBindParams() as $key => $value )
49
-			$this->queryStructure->setParams( $key, $value );
49
+		foreach ( $query->getBindParams() as $key => $value ) {
50
+					$this->queryStructure->setParams( $key, $value );
51
+		}
50 52
 
51 53
 		$this->queryStructure->replaceElement( QueryStructure::SET_FIELDS, $query );
52 54
 
@@ -59,8 +61,9 @@  discard block
 block discarded – undo
59 61
 	 */
60 62
 	private function setFieldsList( $fieldList )
61 63
 	{
62
-		if ( !is_array( $fieldList ) )
63
-			$fieldList = QueryHelper::explode( $fieldList );
64
+		if ( !is_array( $fieldList ) ) {
65
+					$fieldList = QueryHelper::explode( $fieldList );
66
+		}
64 67
 
65 68
 		$this->queryStructure->replaceElement( QueryStructure::FIELDS, $fieldList );
66 69
 
@@ -74,13 +77,15 @@  discard block
 block discarded – undo
74 77
 	private function addSingleRow( array $rowValues )
75 78
 	{
76 79
 
77
-		if ( $this->getNumberOfFields() !== count( $rowValues ) )
78
-			throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT );
80
+		if ( $this->getNumberOfFields() !== count( $rowValues ) ) {
81
+					throw new QueryException( 'Ivalid number of fields.', QueryException::QUERY_ERROR_INVALID_FIELDS_COUNT );
82
+		}
79 83
 
80 84
 		$pdoRowValues = array();
81 85
 
82
-		foreach ( $rowValues as $value )
83
-			$pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value );
86
+		foreach ( $rowValues as $value ) {
87
+					$pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value );
88
+		}
84 89
 
85 90
 		$pdoRowValuesString = '( ' . QueryHelper::implode( $pdoRowValues, ', ' ) . ' )';
86 91
 
@@ -94,8 +99,9 @@  discard block
 block discarded – undo
94 99
 	 */
95 100
 	private function getInsertMultipleRowsSyntax()
96 101
 	{
97
-		if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) )
98
-			return $this->getSyntaxWithSelect();
102
+		if ( is_a( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), QuerySelect::class ) ) {
103
+					return $this->getSyntaxWithSelect();
104
+		}
99 105
 
100 106
 		$fields = '( ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::FIELDS ), ', ' ) . ' )';
101 107
 		$values = QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ), ', ' );
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@
 block discarded – undo
80 80
 		$pdoRowValues = array();
81 81
 
82 82
 		foreach ( $rowValues as $value )
83
-			$pdoRowValues[] = $this->queryStructure->bindParam( 'value', $value );
83
+			$pdoRowValues[ ] = $this->queryStructure->bindParam( 'value', $value );
84 84
 
85 85
 		$pdoRowValuesString = '( ' . QueryHelper::implode( $pdoRowValues, ', ' ) . ' )';
86 86
 
Please login to merge, or discard this patch.
src/Traits/WhereAndHavingBuilder.php 2 patches
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -61,10 +61,11 @@  discard block
 block discarded – undo
61 61
 			case 'IN':
62 62
 			case 'NOT IN':
63 63
 			case '!IN':
64
-				if ( is_a( $value, QuerySelect::class ) )
65
-					return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType );
66
-				elseif ( is_array( $value ) )
67
-					return $this->inArray( $field, $value, $operator, $glue, $clauseType );
64
+				if ( is_a( $value, QuerySelect::class ) ) {
65
+									return $this->inSelectObject( $field, $value, $operator, $glue, $clauseType );
66
+				} elseif ( is_array( $value ) ) {
67
+									return $this->inArray( $field, $value, $operator, $glue, $clauseType );
68
+				}
68 69
 				break;
69 70
 
70 71
 			default:
@@ -155,8 +156,9 @@  discard block
 block discarded – undo
155 156
 	 */
156 157
 	private function getWhereAndHavingSyntax( $clauseType )
157 158
 	{
158
-		if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 )
159
-			return '';
159
+		if ( count( $this->queryStructure->getElement( $clauseType ) ) == 0 ) {
160
+					return '';
161
+		}
160 162
 
161 163
 		$where = '';
162 164
 		$last_type = 'where_start';
@@ -185,11 +187,13 @@  discard block
 block discarded – undo
185 187
 	 */
186 188
 	private function validateWhereParam( $param )
187 189
 	{
188
-		if ( count( $param ) < 2 )
189
-			throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY );
190
+		if ( count( $param ) < 2 ) {
191
+					throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY );
192
+		}
190 193
 
191
-		if ( count( $param ) == 2 )
192
-			$param[] = '=';
194
+		if ( count( $param ) == 2 ) {
195
+					$param[] = '=';
196
+		}
193 197
 
194 198
 		$param[2] = trim( strtoupper( $param[2] ) );
195 199
 		$param[2] = QueryHelper::clearMultipleSpaces( $param[2] );
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
 
38 38
 		$param = $this->validateWhereParam( $param );
39 39
 
40
-		$field = $param[0];
41
-		$value = $param[1];
42
-		$operator = $param[2];
40
+		$field = $param[ 0 ];
41
+		$value = $param[ 1 ];
42
+		$operator = $param[ 2 ];
43 43
 
44 44
 		switch ( $operator ) {
45 45
 			case 'BETWEEN':
46 46
 			case 'NOT BETWEEN':
47 47
 			case '!BETWEEN':
48
-				$min = $value[0];
49
-				$max = $value[1];
48
+				$min = $value[ 0 ];
49
+				$max = $value[ 1 ];
50 50
 				$body = [
51 51
 					$field,
52 52
 					$operator,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	{
119 119
 		$pdoArray = array();
120 120
 		foreach ( $value as $item ) {
121
-			$pdoArray[] = $this->queryStructure->bindParam( 'a', $item );
121
+			$pdoArray[ ] = $this->queryStructure->bindParam( 'a', $item );
122 122
 		}
123 123
 		$body = [
124 124
 			$field,
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	private function getWhereSyntax()
140 140
 	{
141
-		return $this->getWhereAndHavingSyntax(QueryStructure::WHERE);
141
+		return $this->getWhereAndHavingSyntax( QueryStructure::WHERE );
142 142
 	}
143 143
 
144 144
 	/**
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	private function getHavingSyntax()
148 148
 	{
149
-		return $this->getWhereAndHavingSyntax( QueryStructure::HAVING);
149
+		return $this->getWhereAndHavingSyntax( QueryStructure::HAVING );
150 150
 	}
151 151
 
152 152
 	/**
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 		$where = '';
162 162
 		$last_type = 'where_start';
163 163
 		foreach ( $this->queryStructure->getElement( $clauseType ) as $where_cond ) {
164
-			$glue = $where_cond['glue'];
164
+			$glue = $where_cond[ 'glue' ];
165 165
 			if ( $last_type == 'where_start' || $last_type == 'start_where_group' ) {
166 166
 				$glue = '';
167 167
 			}
168
-			$where .= ' ' . $glue . ' ' . $where_cond['body'];
169
-			$last_type = $where_cond['type'];
168
+			$where .= ' ' . $glue . ' ' . $where_cond[ 'body' ];
169
+			$last_type = $where_cond[ 'type' ];
170 170
 		}
171 171
 
172
-		if ( $this->queryStructure->getElement( $clauseType.'_invert' ) ) {
172
+		if ( $this->queryStructure->getElement( $clauseType . '_invert' ) ) {
173 173
 			$where = ' NOT ( ' . $where . ' ) ';
174 174
 		}
175 175
 
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 			throw new QueryException( 'Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY );
190 190
 
191 191
 		if ( count( $param ) == 2 )
192
-			$param[] = '=';
192
+			$param[ ] = '=';
193 193
 
194
-		$param[2] = trim( strtoupper( $param[2] ) );
195
-		$param[2] = QueryHelper::clearMultipleSpaces( $param[2] );
194
+		$param[ 2 ] = trim( strtoupper( $param[ 2 ] ) );
195
+		$param[ 2 ] = QueryHelper::clearMultipleSpaces( $param[ 2 ] );
196 196
 
197 197
 		return $param;
198 198
 	}
Please login to merge, or discard this patch.
src/Traits/SetFields.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,8 +48,9 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	public function setFieldsByArray( array $updateFieldsArray )
50 50
 	{
51
-		foreach ( $updateFieldsArray as $fieldName => $fieldValue )
52
-			$this->setField( $fieldName, $fieldValue );
51
+		foreach ( $updateFieldsArray as $fieldName => $fieldValue ) {
52
+					$this->setField( $fieldName, $fieldValue );
53
+		}
53 54
 
54 55
 		return $this;
55 56
 	}
@@ -59,8 +60,9 @@  discard block
 block discarded – undo
59 60
 	 */
60 61
 	private function getSettingFieldsSyntax()
61 62
 	{
62
-		if ( !count( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) ) )
63
-			return '';
63
+		if ( !count( $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) ) ) {
64
+					return '';
65
+		}
64 66
 
65 67
 		return 'SET ' . implode( ', ', $this->queryStructure->getElement( QueryStructure::SET_FIELDS ) );
66 68
 	}
Please login to merge, or discard this patch.