Completed
Pull Request — master (#25)
by Adeniyi
02:25
created
src/Database/DatabaseQuery.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     protected static function checkConnection($con)
51 51
     {
52
-        if( $con === null )
52
+        if ($con === null)
53 53
         {
54 54
             $con = self::connect();
55 55
         }
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
      *
65 65
      * @return bool
66 66
      */
67
-    public function checkTableExist($table, $con=NULL)
67
+    public function checkTableExist($table, $con = NULL)
68 68
     {
69 69
         $connection = $this->checkConnection($con);
70 70
         $query = $connection->query("SELECT 1 FROM {$table} LIMIT 1");
71
-        if( $query !== false )
71
+        if ($query !== false)
72 72
         {
73 73
             return true;
74 74
         }
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @return string
84 84
      */
85
-    public static function checkTableName($tableName, $con=NULL)
85
+    public static function checkTableName($tableName, $con = NULL)
86 86
     {
87 87
         $connection = self::checkConnection($con);
88 88
 
89 89
         $query = $connection->query("SELECT 1 FROM {$tableName} LIMIT 1");
90
-        if( $query !== false )
90
+        if ($query !== false)
91 91
         {
92 92
             return $tableName;
93 93
         }
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
      *
104 104
      * @return string
105 105
      */
106
-    protected static function checkColumn($tableName, $columnName, $con=NULL)
106
+    protected static function checkColumn($tableName, $columnName, $con = NULL)
107 107
     {
108 108
         $connection = self::checkConnection($con);
109 109
 
110 110
             $result = $connection->prepare("SELECT {$columnName} FROM {$tableName}");
111 111
             $result->execute();
112
-            if ( ! $result->columnCount() )
112
+            if ( ! $result->columnCount())
113 113
             {
114 114
                 throw new ColumnNotExistExeption();
115 115
             }
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
         $columnNames = self::getColumns($getClassVars);
153 153
         $arraySize = count($columnNames);
154 154
 
155
-        foreach ( $columnNames as $key => $value )
155
+        foreach ($columnNames as $key => $value)
156 156
         {
157 157
             $counter++;
158 158
             $insertQuery .= self::sanitize($key);
159
-            if( $arraySize > $counter )
159
+            if ($arraySize > $counter)
160 160
                 $insertQuery .= ", ";
161 161
         }
162 162
 
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
         $columnNames = self::getColumns($getClassVars);
178 178
         $arraySize = count($columnNames);
179 179
 
180
-        foreach ( $columnNames as $key => $value )
180
+        foreach ($columnNames as $key => $value)
181 181
         {
182 182
             $counter++;
183
-            $insertQuery .= "'".self::sanitize($value) ."'";
184
-            if( $arraySize > $counter )
183
+            $insertQuery .= "'".self::sanitize($value)."'";
184
+            if ($arraySize > $counter)
185 185
                 $insertQuery .= ", ";
186 186
         }
187 187
         return $insertQuery;
@@ -200,12 +200,12 @@  discard block
 block discarded – undo
200 200
         $updateQuery = "";
201 201
         $arraySize = count($data);
202 202
 
203
-        foreach ( $data as $key => $value )
203
+        foreach ($data as $key => $value)
204 204
         {
205 205
             $counter++;
206 206
             $columnName = self::checkColumn($tableName, self::sanitize($key));
207
-            $updateQuery .= $columnName ." = '".self::sanitize($value)."'";
208
-            if ( $arraySize > $counter )
207
+            $updateQuery .= $columnName." = '".self::sanitize($value)."'";
208
+            if ($arraySize > $counter)
209 209
             {
210 210
                 $updateQuery .= ", ";
211 211
             }
@@ -234,14 +234,14 @@  discard block
 block discarded – undo
234 234
         $counter = 0;
235 235
         $arraySize = count($data);
236 236
 
237
-        foreach ( $data as $key => $value )
237
+        foreach ($data as $key => $value)
238 238
         {
239 239
             $counter++;
240 240
             $columnName = self::checkColumn($tableName, self::sanitize($key));
241
-            $where .= $columnName ." = '".self::sanitize($value)."'";
242
-            if ( $arraySize > $counter )
241
+            $where .= $columnName." = '".self::sanitize($value)."'";
242
+            if ($arraySize > $counter)
243 243
             {
244
-                $where .= " " . $condition . " ";
244
+                $where .= " ".$condition." ";
245 245
             }
246 246
         }
247 247
 
@@ -259,14 +259,14 @@  discard block
 block discarded – undo
259 259
         try
260 260
         {
261 261
             $arraySize = count($data);
262
-            if( $arraySize > 1 && $condition == NULL)
262
+            if ($arraySize > 1 && $condition == NULL)
263 263
             {
264 264
                 $query = "Please Supply the condition";
265 265
             }
266 266
             else
267 267
             {
268 268
                 $columnName = self::whereAndClause($tableName, $data, $condition);
269
-                $query =  "SELECT $fields FROM $tableName WHERE $columnName";
269
+                $query = "SELECT $fields FROM $tableName WHERE $columnName";
270 270
             }
271 271
         } catch (PDOException $e) {
272 272
             $query = $e->getMessage();
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      */
283 283
     public function insertQuery($tableName)
284 284
     {
285
-        $data = ( array )$this;
285
+        $data = (array)$this;
286 286
         array_shift($data);
287 287
 
288 288
         $columnNames = self::buildColumn($data);
@@ -298,11 +298,11 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function updateQuery($tableName)
300 300
     {
301
-        $data = ( array ) $this;
301
+        $data = (array)$this;
302 302
         $data = array_slice($data, 2);
303 303
 
304 304
         $values = self::buildClause($tableName, $data);
305
-        $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ". self::sanitize($this->id);
305
+        $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ".self::sanitize($this->id);
306 306
 
307 307
         return $updateQuery;
308 308
     }
Please login to merge, or discard this patch.
src/Helper/Schema.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
      *
26 26
      * @return array
27 27
      */
28
-    public function field($type, $fieldName, $length=NULL)
28
+    public function field($type, $fieldName, $length = NULL)
29 29
     {
30
-        if($length === null){
31
-             $this->fieldDescription[] = $type ." ".$fieldName;
32
-        }else
30
+        if ($length === null) {
31
+             $this->fieldDescription[] = $type." ".$fieldName;
32
+        } else
33 33
         {
34
-         $this->fieldDescription[] = $type ." ".$fieldName." ".$length;
34
+         $this->fieldDescription[] = $type." ".$fieldName." ".$length;
35 35
         }
36 36
 
37 37
     }
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
             $fields = explode(" ", $fieldName);
52 52
          
53 53
             $constrain = $fields[0];
54
-            if(count($fields) == 2)
54
+            if (count($fields) == 2)
55 55
             {
56
-                $query .= $this->$constrain($fields[1], 20) .", ".PHP_EOL;
57
-            }else
56
+                $query .= $this->$constrain($fields[1], 20).", ".PHP_EOL;
57
+            } else
58 58
             {
59
-                    $query .= $this->$constrain($fields[1], $fields[2]) .", ".PHP_EOL;
59
+                    $query .= $this->$constrain($fields[1], $fields[2]).", ".PHP_EOL;
60 60
             }
61 61
         };
62 62
         array_walk($this->fieldDescription, $callback);
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
         {
91 91
             $sqlQuery = self::sanitizeQuery($tablename);
92 92
             $query = $connection->prepare($sqlQuery);
93
-            if($query->execute())
93
+            if ($query->execute())
94 94
             {
95 95
                 return true;
96 96
             }
97
-        }catch(PDOException $e){
97
+        } catch (PDOException $e) {
98 98
             return $e->getMessage();
99 99
         }
100 100
     }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     public function strings($value, $length)
118 118
     {
119
-        return $value ." varchar (".$length.") NOT NULL";
119
+        return $value." varchar (".$length.") NOT NULL";
120 120
     }
121 121
 
122 122
     /**
@@ -202,6 +202,6 @@  discard block
 block discarded – undo
202 202
                     $apend = 'timestamp';
203 203
                 break;
204 204
         }
205
-        return $value . " " . $apend . " NOT NULL";
205
+        return $value." ".$apend." NOT NULL";
206 206
     }
207 207
 }
208 208
\ No newline at end of file
Please login to merge, or discard this patch.
src/Helper/Upload.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
         $Extension = strtolower($FileParts['extension']);
74 74
         $ValidExtensions = $this->ValidExtensions;
75 75
 
76
-        if (!$FileName) {
76
+        if ( ! $FileName) {
77 77
             $this->SetMessage("ERROR: File name is empty.");
78 78
             return false;
79 79
         }
80 80
 
81
-        if (!$ValidExtensions) {
81
+        if ( ! $ValidExtensions) {
82 82
             $this->SetMessage("WARNING: All extensions are valid.");
83 83
             return true;
84 84
         }
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $TempFileName = $this->GetTempName();
105 105
         $TempFileSize = filesize($TempFileName);
106 106
 
107
-        if($MaximumFileSize == "") {
107
+        if ($MaximumFileSize == "") {
108 108
             $this->SetMessage("WARNING: There is no size restriction.");
109 109
             return true;
110 110
         }
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $FileName = $this->FileName;
129 129
         $UploadDirectory = $this->UploadDirectory;
130
-        $File = $UploadDirectory . $FileName;
130
+        $File = $UploadDirectory.$FileName;
131 131
 
132 132
         if (file_exists($File)) {
133 133
             $this->SetMessage("Message: The file '$FileName' already exist.");
134
-            $UniqueName = rand() . $FileName;
134
+            $UniqueName = rand().$FileName;
135 135
             $this->SetFileName($UniqueName);
136 136
             $this->ValidateExistance();
137 137
         } else {
@@ -149,24 +149,24 @@  discard block
 block discarded – undo
149 149
     {
150 150
         $UploadDirectory = $this->UploadDirectory;
151 151
 
152
-        if (!$UploadDirectory) {
152
+        if ( ! $UploadDirectory) {
153 153
             $this->SetMessage("ERROR: The directory variable is empty.");
154 154
             return false;
155 155
         }
156 156
 
157
-        if (!is_dir($UploadDirectory)) {
157
+        if ( ! is_dir($UploadDirectory)) {
158 158
             $this->SetMessage("ERROR: The directory '$UploadDirectory' does not exist.");
159 159
             return false;
160 160
         }
161 161
 
162
-        if (!is_writable($UploadDirectory)) {
162
+        if ( ! is_writable($UploadDirectory)) {
163 163
             $this->SetMessage("ERROR: The directory '$UploadDirectory' does not writable.");
164 164
             return false;
165 165
         }
166 166
 
167 167
         if (substr($UploadDirectory, -1) != "/") {
168 168
             $this->SetMessage("ERROR: The traling slash does not exist.");
169
-            $NewDirectory = $UploadDirectory . "/";
169
+            $NewDirectory = $UploadDirectory."/";
170 170
             $this->SetUploadDirectory($NewDirectory);
171 171
             $this->ValidateDirectory();
172 172
         } else {
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
         $MaximumHeight = $this->MaximumHeight;
186 186
         $TempFileName = $this->TempFileName;
187 187
 
188
-    if($Size = @getimagesize($TempFileName)) {
189
-        $Width = $Size[0];   //$Width is the width in pixels of the image uploaded to the server.
190
-        $Height = $Size[1];  //$Height is the height in pixels of the image uploaded to the server.
188
+    if ($Size = @getimagesize($TempFileName)) {
189
+        $Width = $Size[0]; //$Width is the width in pixels of the image uploaded to the server.
190
+        $Height = $Size[1]; //$Height is the height in pixels of the image uploaded to the server.
191 191
     }
192 192
 
193 193
         if ($Width > $MaximumWidth) {
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
     public function uploadFile()
213 213
     {
214 214
 
215
-        if (!$this->ValidateExtension()) {
215
+        if ( ! $this->ValidateExtension()) {
216 216
             die($this->GetMessage());
217 217
         } 
218 218
 
219
-        else if (!$this->ValidateSize()) {
219
+        else if ( ! $this->ValidateSize()) {
220 220
             die($this->GetMessage());
221 221
         }
222 222
 
@@ -224,11 +224,11 @@  discard block
 block discarded – undo
224 224
             die($this->GetMessage());
225 225
         }
226 226
 
227
-        else if (!$this->ValidateDirectory()) {
227
+        else if ( ! $this->ValidateDirectory()) {
228 228
             die($this->GetMessage());
229 229
         }
230 230
 
231
-        else if ($this->IsImage && !$this->ValidateImage()) {
231
+        else if ($this->IsImage && ! $this->ValidateImage()) {
232 232
             die($this->GetMessage());
233 233
         }
234 234
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             $UploadDirectory = $this->UploadDirectory;
240 240
 
241 241
             if (is_uploaded_file($TempFileName)) { 
242
-                move_uploaded_file($TempFileName, $UploadDirectory . $FileName);
242
+                move_uploaded_file($TempFileName, $UploadDirectory.$FileName);
243 243
                 return true;
244 244
             } else {
245 245
                 return false;
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 
323 323
     public function GetMessage()
324 324
     {
325
-        if (!isset($this->Message)) {
325
+        if ( ! isset($this->Message)) {
326 326
             $this->SetMessage("No Message");
327 327
         }
328 328
 
Please login to merge, or discard this patch.