Passed
Push — master ( 289635...077925 )
by Adrian
02:39
created
src/Statements/QueryDelete.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,8 +96,9 @@
 block discarded – undo
96 96
 	 */
97 97
 	public function execute()
98 98
 	{
99
-		if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) )
100
-			throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER );
99
+		if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) {
100
+					throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER );
101
+		}
101 102
 
102 103
 		return PdoWrapperService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS))->rowCount();
103 104
 	}
Please login to merge, or discard this patch.
src/Statements/QuerySelect.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,8 +56,9 @@  discard block
 block discarded – undo
56 56
 			$this->queryStructure->setElement( QueryStructure::TABLE, $tableName );
57 57
 
58 58
 			$tableSelectParams = $table->getBindParams();
59
-			foreach ( $tableSelectParams as $key => $value )
60
-				$this->queryStructure->setParams( $key, $value );
59
+			foreach ( $tableSelectParams as $key => $value ) {
60
+							$this->queryStructure->setParams( $key, $value );
61
+			}
61 62
 
62 63
 		}
63 64
 	}
@@ -112,8 +113,9 @@  discard block
 block discarded – undo
112 113
 			$this->queryStructure->setElement( QueryStructure::DISTINCT, 0 ); //???
113 114
 		}
114 115
 
115
-		if ( $this->queryStructure->getElement( QueryStructure::FIRST ) )
116
-			$this->queryStructure->setElement( QueryStructure::LIMIT, 1 );
116
+		if ( $this->queryStructure->getElement( QueryStructure::FIRST ) ) {
117
+					$this->queryStructure->setElement( QueryStructure::LIMIT, 1 );
118
+		}
117 119
 
118 120
 		$syntax = array();
119 121
 
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
@@ -107,8 +107,9 @@
 block discarded – undo
107 107
 	 */
108 108
 	public function execute()
109 109
 	{
110
-		if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) )
111
-			throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER );
110
+		if ( $this->queryStructure->getElement( ( QueryStructure::WHERE_TRIGGER ) ) && !count( $this->queryStructure->getElement( QueryStructure::WHERE ) ) ) {
111
+					throw new QueryException( 'Where clause is required for this statement!', QueryException::QUERY_ERROR_DELETE_NOT_FILTER );
112
+		}
112 113
 
113 114
 		return PdoWrapperService::getInstance()->query($this->getSyntax(), $this->queryStructure->getElement(QueryStructure::BIND_PARAMS))->rowCount();
114 115
 	}
Please login to merge, or discard this patch.
src/AbstractCruds/AbstractTableCrud.php 1 patch
Braces   +21 added lines, -14 removed lines patch added patch discarded remove patch
@@ -57,8 +57,9 @@  discard block
 block discarded – undo
57 57
 	{
58 58
 		$conditions = $this->getPrimaryKeyConditions( $id );
59 59
 		$result = QueryBuild::select( $this->table )->fields( $fields );
60
-		foreach ( $conditions as $field => $value )
61
-			$result->whereEqual( $field, $value );
60
+		foreach ( $conditions as $field => $value ) {
61
+					$result->whereEqual( $field, $value );
62
+		}
62 63
 
63 64
 		return $result->first()->execute();
64 65
 	}
@@ -73,8 +74,9 @@  discard block
 block discarded – undo
73 74
 	{
74 75
 		$conditions = $this->getPrimaryKeyConditions( $id );
75 76
 		$result = QueryBuild::delete( $this->table );
76
-		foreach ( $conditions as $field => $value )
77
-			$result->whereEqual( $field, $value );
77
+		foreach ( $conditions as $field => $value ) {
78
+					$result->whereEqual( $field, $value );
79
+		}
78 80
 
79 81
 		return $result->execute();
80 82
 	}
@@ -89,8 +91,9 @@  discard block
 block discarded – undo
89 91
 	{
90 92
 		$conditions = $this->getPrimaryKeyConditions( $id );
91 93
 		$result = QueryBuild::update( $this->table );
92
-		foreach ( $conditions as $field => $value )
93
-			$result->whereEqual( $field, $value );
94
+		foreach ( $conditions as $field => $value ) {
95
+					$result->whereEqual( $field, $value );
96
+		}
94 97
 		$result->setFieldsByArray( $arrayUpdater );
95 98
 
96 99
 		return $result->execute();
@@ -115,8 +118,9 @@  discard block
 block discarded – undo
115 118
 	 */
116 119
 	public function saveOrder( $updates_ord = array() )
117 120
 	{
118
-		if ( empty( $this->orderField ) )
119
-			throw new QueryException( 'Order field is not defined' );
121
+		if ( empty( $this->orderField ) ) {
122
+					throw new QueryException( 'Order field is not defined' );
123
+		}
120 124
 
121 125
 		$query = /** @lang text */
122 126
 			"UPDATE `{$this->table}` SET `{$this->orderField}` = CASE `{$this->primary[0]}` \r\n";
@@ -137,16 +141,19 @@  discard block
 block discarded – undo
137 141
 	 */
138 142
 	protected function getPrimaryKeyConditions( $id )
139 143
 	{
140
-		if ( !is_array( $id ) )
141
-			$id = [ $id ];
144
+		if ( !is_array( $id ) ) {
145
+					$id = [ $id ];
146
+		}
142 147
 
143
-		if ( count( $this->primary ) !== count( $id ) )
144
-			throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY );
148
+		if ( count( $this->primary ) !== count( $id ) ) {
149
+					throw new QueryException( 'Invalid primary key', QueryException::QUERY_CRUD_INVALID_PRIMARY );
150
+		}
145 151
 
146 152
 		$conditions = [];
147 153
 
148
-		foreach ( $this->primary as $index => $key )
149
-			$conditions[ $key ] = $id[ $index ];
154
+		foreach ( $this->primary as $index => $key ) {
155
+					$conditions[ $key ] = $id[ $index ];
156
+		}
150 157
 
151 158
 		return $conditions;
152 159
 	}
Please login to merge, or discard this patch.
src/Traits/TableValidation.php 1 patch
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,8 +49,9 @@  discard block
 block discarded – undo
49 49
 	{
50 50
 		$table = trim( $table );
51 51
 
52
-		if ( '' === $table )
53
-			throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
52
+		if ( '' === $table ) {
53
+					throw new QueryException( 'Table name is empty string!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
54
+		}
54 55
 
55 56
 		return QueryHelper::addBacktick($table);
56 57
 	}
@@ -62,11 +63,13 @@  discard block
 block discarded – undo
62 63
 	 */
63 64
 	private function validateTableSubQuery( $table )
64 65
 	{
65
-		if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT )
66
-			throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
66
+		if ( $this->statement !== QueryStatement::QUERY_STATEMENT_SELECT ) {
67
+					throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
68
+		}
67 69
 
68
-		if ( !is_a( $table, QuerySelect::class ) )
69
-			throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
70
+		if ( !is_a( $table, QuerySelect::class ) ) {
71
+					throw new QueryException( 'Invalid subQuery statement!', QueryException::QUERY_ERROR_INVALID_TABLE_STATEMENT );
72
+		}
70 73
 
71 74
 		return $table;
72 75
 	}
Please login to merge, or discard this patch.
src/Traits/Utilities.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,8 +34,9 @@
 block discarded – undo
34 34
 	 */
35 35
 	protected function getExplainSyntax()
36 36
 	{
37
-		if ( $this->queryStructure->getElement( QueryStructure::EXPLAIN ) )
38
-			return 'EXPLAIN';
37
+		if ( $this->queryStructure->getElement( QueryStructure::EXPLAIN ) ) {
38
+					return 'EXPLAIN';
39
+		}
39 40
 
40 41
 		return '';
41 42
 	}
Please login to merge, or discard this patch.
src/Traits/OrderBy.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
 	public function orderBy( $column, array $allowedColumns = [] )
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
 		$column = $this->queryStructure->prepare($column);
35 36
 		$this->queryStructure->setElement( QueryStructure::ORDER_BY, $column );
@@ -46,8 +47,9 @@  discard block
 block discarded – undo
46 47
 	 */
47 48
 	public function orderByDesc( $column, array $allowedColumns = [] )
48 49
 	{
49
-		if ( !$this->validateColumn( $column, $allowedColumns ) )
50
-			throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
50
+		if ( !$this->validateColumn( $column, $allowedColumns ) ) {
51
+					throw new QueryException( 'Invalid column name in ORDER BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
52
+		}
51 53
 
52 54
 		$column = $this->queryStructure->prepare($column);
53 55
 		$this->queryStructure->setElement( QueryStructure::ORDER_BY, $column . ' DESC' );
@@ -74,8 +76,9 @@  discard block
 block discarded – undo
74 76
 	 */
75 77
 	private function getOrderBySyntax()
76 78
 	{
77
-		if ( count( $this->queryStructure->getElement( QueryStructure::ORDER_BY ) ) )
78
-			return 'ORDER BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::ORDER_BY ), ', ' );
79
+		if ( count( $this->queryStructure->getElement( QueryStructure::ORDER_BY ) ) ) {
80
+					return 'ORDER BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::ORDER_BY ), ', ' );
81
+		}
79 82
 
80 83
 		return '';
81 84
 	}
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
@@ -26,11 +26,13 @@
 block discarded – undo
26 26
 	 */
27 27
 	protected function validateColumn( $columnName, array $allowed )
28 28
 	{
29
-		if ( is_integer( $columnName ) )
30
-			return true;
29
+		if ( is_integer( $columnName ) ) {
30
+					return true;
31
+		}
31 32
 
32
-		if ( !count( $allowed ) )
33
-			return true;
33
+		if ( !count( $allowed ) ) {
34
+					return true;
35
+		}
34 36
 
35 37
 		return false;
36 38
 	}
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
 	public function groupBy( $column, array $allowedColumns = [] )
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
 		$column = $this->queryStructure->prepare($column);
35 36
 		$this->queryStructure->setElement( QueryStructure::ORDER_BY, $column );
@@ -48,8 +49,9 @@  discard block
 block discarded – undo
48 49
 	 */
49 50
 	public function groupByDesc( $column, array $allowedColumns = [] )
50 51
 	{
51
-		if ( !$this->validateColumn( $column, $allowedColumns ) )
52
-			throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
52
+		if ( !$this->validateColumn( $column, $allowedColumns ) ) {
53
+					throw new QueryException( 'Invalid column name in GROUP BY clause', QueryException::QUERY_ERROR_INVALID_COLUMN_NAME );
54
+		}
53 55
 
54 56
 		$column = $this->queryStructure->prepare($column);
55 57
 		$this->queryStructure->setElement( QueryStructure::ORDER_BY, $column );
@@ -78,8 +80,9 @@  discard block
 block discarded – undo
78 80
 	 */
79 81
 	private function getGroupBySyntax()
80 82
 	{
81
-		if ( count( $this->queryStructure->getElement( QueryStructure::GROUP_BY ) ) )
82
-			return 'GROUP BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::GROUP_BY ), ', ' );
83
+		if ( count( $this->queryStructure->getElement( QueryStructure::GROUP_BY ) ) ) {
84
+					return 'GROUP BY ' . QueryHelper::implode( $this->queryStructure->getElement( QueryStructure::GROUP_BY ), ', ' );
85
+		}
83 86
 
84 87
 		return '';
85 88
 	}
Please login to merge, or discard this patch.