Passed
Push — master ( d44413...7ff405 )
by Adrian
04:24
created
src/Traits/InsertMultiple.php 1 patch
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.
src/Traits/SelectFields.php 1 patch
Braces   +16 added lines, -10 removed lines patch added patch discarded remove patch
@@ -30,17 +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)); else
35
-                    $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
+                    }
36 38
                 break;
37 39
 
38 40
             case QueryStructure::ELEMENT_TYPE_STRING:
39 41
 
40 42
                 $fields = trim($fields);
41
-                if ('' !== $fields)
42
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, $fields); else
43
-                    $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
43
+                if ('' !== $fields) {
44
+                                    $this->queryStructure->setElement(QueryStructure::FIELDS, $fields);
45
+                } else {
46
+                                        $this->queryStructure->setElement(QueryStructure::FIELDS, '*');
47
+                    }
44 48
                 break;
45 49
 
46 50
             default:
@@ -61,11 +65,13 @@  discard block
 block discarded – undo
61 65
         $prepareArray = [];
62 66
 
63 67
         foreach ($fieldsArray as $field) {
64
-            if (gettype($field) !== QueryStructure::ELEMENT_TYPE_STRING)
65
-                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
+            }
66 71
 
67
-            if ('' !== trim($field))
68
-                $prepareArray[] = trim($field);
72
+            if ('' !== trim($field)) {
73
+                            $prepareArray[] = trim($field);
74
+            }
69 75
         }
70 76
 
71 77
         return $prepareArray;
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/Traits/Replacement.php 1 patch
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.
src/Traits/WhereAndHavingBuilder.php 1 patch
Braces   +14 added lines, -9 removed lines patch added patch discarded remove patch
@@ -55,9 +55,11 @@  discard block
 block discarded – undo
55 55
             case 'IN':
56 56
             case 'NOT IN':
57 57
             case '!IN':
58
-                if (is_a($value, QuerySelect::class))
59
-                    return $this->inSelectObject($field, $value, $operator, $glue, $clauseType); elseif (is_array($value))
60
-                    return $this->inArray($field, $value, $operator, $glue, $clauseType);
58
+                if (is_a($value, QuerySelect::class)) {
59
+                                    return $this->inSelectObject($field, $value, $operator, $glue, $clauseType);
60
+                } elseif (is_array($value)) {
61
+                                        return $this->inArray($field, $value, $operator, $glue, $clauseType);
62
+                    }
61 63
                 break;
62 64
 
63 65
             default:
@@ -138,8 +140,9 @@  discard block
 block discarded – undo
138 140
      */
139 141
     private function getWhereAndHavingSyntax($clauseType)
140 142
     {
141
-        if (count($this->queryStructure->getElement($clauseType)) == 0)
142
-            return '';
143
+        if (count($this->queryStructure->getElement($clauseType)) == 0) {
144
+                    return '';
145
+        }
143 146
 
144 147
         $where = '';
145 148
         $last_type = 'where_start';
@@ -168,11 +171,13 @@  discard block
 block discarded – undo
168 171
      */
169 172
     private function validateWhereParam($param)
170 173
     {
171
-        if (count($param) < 2)
172
-            throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
174
+        if (count($param) < 2) {
175
+                    throw new QueryException('Invalid where array!', QueryException::QUERY_ERROR_WHERE_INVALID_PARAM_ARRAY);
176
+        }
173 177
 
174
-        if (count($param) == 2)
175
-            $param[] = '=';
178
+        if (count($param) == 2) {
179
+                    $param[] = '=';
180
+        }
176 181
 
177 182
         $param[2] = trim(strtoupper($param[2]));
178 183
         $param[2] = QueryHelper::clearMultipleSpaces($param[2]);
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.
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
         $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/Join.php 1 patch
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,9 +116,11 @@
 block discarded – undo
116 116
     {
117 117
         $join = $typeJoin . ' ' . $tableJoin;
118 118
 
119
-        if (is_null($onRight))
120
-            $join .= " USING ( $onLeft )"; else
121
-            $join .= " ON $onLeft = $onRight";
119
+        if (is_null($onRight)) {
120
+                    $join .= " USING ( $onLeft )";
121
+        } else {
122
+                        $join .= " ON $onLeft = $onRight";
123
+            }
122 124
 
123 125
         $this->queryStructure->setElement(QueryStructure::JOIN, $join);
124 126
 
Please login to merge, or discard this patch.
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.