Completed
Pull Request — master (#20)
by Adeniyi
02:52
created
src/Interface/GetDataInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Defining Interface for class GetData.
4
- *
5
- * @package Ibonly\PotatoORM\ModelInterface
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * Defining Interface for class GetData.
4
+     *
5
+     * @package Ibonly\PotatoORM\ModelInterface
6
+     * @author  Ibraheem ADENIYI <[email protected]>
7
+     * @license MIT <https://opensource.org/licenses/MIT>
8
+     */
9 9
 
10 10
 namespace Ibonly\PotatoORM;
11 11
 
Please login to merge, or discard this patch.
src/Interface/ModelInterface.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Defining Interface for class Model.
4
- *
5
- * @package Ibonly\PotatoORM\ModelInterface
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * Defining Interface for class Model.
4
+     *
5
+     * @package Ibonly\PotatoORM\ModelInterface
6
+     * @author  Ibraheem ADENIYI <[email protected]>
7
+     * @license MIT <https://opensource.org/licenses/MIT>
8
+     */
9 9
 
10 10
 namespace Ibonly\PotatoORM;
11 11
 
Please login to merge, or discard this patch.
src/Helper/GetData.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@
 block discarded – undo
53 53
     /**
54 54
      * Get the count of the fetch element
55 55
      */
56
-   public function getCount()
57
-   {
56
+    public function getCount()
57
+    {
58 58
         return sizeof($this->value);
59
-   }
59
+    }
60 60
 }
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
     public function all()
25 25
     {
26
-        return json_decode( json_encode( $this->getAllData() ) );
26
+        return json_decode(json_encode($this->getAllData()));
27 27
     }
28 28
 
29 29
     /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function first()
49 49
     {
50
-        return json_decode( $this->toJson() );
50
+        return json_decode($this->toJson());
51 51
     }
52 52
 
53 53
     /**
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
     }
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
         $callback = function($fieldName) use (&$query)
50 50
         {
51 51
             $e = explode(" ", $fieldName);
52
-            if(count($e) == 2)
52
+            if (count($e) == 2)
53 53
             {
54
-                $query .= $this->$e[0]($e[1], 20) .", ".PHP_EOL;
55
-            }else
54
+                $query .= $this->$e[0]($e[1], 20).", ".PHP_EOL;
55
+            } else
56 56
             {
57
-                    $query .= $this->$e[0]($e[1], $e[2]) .", ".PHP_EOL;
57
+                    $query .= $this->$e[0]($e[1], $e[2]).", ".PHP_EOL;
58 58
             }
59 59
         };
60 60
         array_walk($this->fieldDescription, $callback);
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
         {
88 88
             $sqlQuery = self::sanitizeQuery($tablename);
89 89
             $query = $connection->prepare($sqlQuery);
90
-            if($query->execute())
90
+            if ($query->execute())
91 91
             {
92 92
                 return true;
93 93
             }
94
-        }catch(PDOException $e){
94
+        } catch (PDOException $e) {
95 95
             return $e->getMessage();
96 96
         }
97 97
     }
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public function strings($value, $length)
115 115
     {
116
-        return $value ." varchar (".$length.") NOT NULL";
116
+        return $value." varchar (".$length.") NOT NULL";
117 117
     }
118 118
 
119 119
     /**
@@ -198,6 +198,6 @@  discard block
 block discarded – undo
198 198
                     $apend = 'timestamp';
199 199
                 break;
200 200
         }
201
-        return $value . " " . $apend . " NOT NULL";
201
+        return $value." ".$apend." NOT NULL";
202 202
     }
203 203
 }
204 204
\ No newline at end of file
Please login to merge, or discard this patch.
src/Database/DatabaseQuery.php 1 patch
Spacing   +26 added lines, -26 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
             }
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
         $insertQuery = "";
130 130
         $arraySize = count($data);
131 131
 
132
-        foreach ( $data as $key => $value )
132
+        foreach ($data as $key => $value)
133 133
         {
134 134
             $counter++;
135 135
             $insertQuery .= self::sanitize($key);
136
-            if( $arraySize > $counter )
136
+            if ($arraySize > $counter)
137 137
                 $insertQuery .= ", ";
138 138
         }
139 139
         return $insertQuery;
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
         $insertQuery = "";
153 153
         $arraySize = count($data);
154 154
 
155
-        foreach ( $data as $key => $value )
155
+        foreach ($data as $key => $value)
156 156
         {
157 157
             $counter++;
158
-            $insertQuery .= "'".self::sanitize($value) ."'";
159
-            if( $arraySize > $counter )
158
+            $insertQuery .= "'".self::sanitize($value)."'";
159
+            if ($arraySize > $counter)
160 160
                 $insertQuery .= ", ";
161 161
         }
162 162
         return $insertQuery;
@@ -175,12 +175,12 @@  discard block
 block discarded – undo
175 175
         $updateQuery = "";
176 176
         $arraySize = count($data);
177 177
 
178
-        foreach ( $data as $key => $value )
178
+        foreach ($data as $key => $value)
179 179
         {
180 180
             $counter++;
181 181
             $columnName = self::checkColumn($tableName, self::sanitize($key));
182
-            $updateQuery .= $columnName ." = '".self::sanitize($value)."'";
183
-            if ( $arraySize > $counter )
182
+            $updateQuery .= $columnName." = '".self::sanitize($value)."'";
183
+            if ($arraySize > $counter)
184 184
             {
185 185
                 $updateQuery .= ", ";
186 186
             }
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
         $counter = 0;
210 210
         $arraySize = count($data);
211 211
 
212
-        foreach ( $data as $key => $value )
212
+        foreach ($data as $key => $value)
213 213
         {
214 214
             $counter++;
215 215
             $columnName = self::checkColumn($tableName, self::sanitize($key));
216
-            $where .= $columnName ." = '".self::sanitize($value)."'";
217
-            if ( $arraySize > $counter )
216
+            $where .= $columnName." = '".self::sanitize($value)."'";
217
+            if ($arraySize > $counter)
218 218
             {
219
-                $where .= " " . $condition . " ";
219
+                $where .= " ".$condition." ";
220 220
             }
221 221
         }
222 222
 
@@ -234,16 +234,16 @@  discard block
 block discarded – undo
234 234
         try
235 235
         {
236 236
             $arraySize = count($data);
237
-            if( $arraySize > 1 && $condition == NULL)
237
+            if ($arraySize > 1 && $condition == NULL)
238 238
             {
239 239
                 $query = "Please Supply the condition";
240 240
             }
241 241
             else
242 242
             {
243 243
                 $columnName = self::whereAndClause($tableName, $data, $condition);
244
-                $query =  "SELECT * FROM $tableName WHERE $columnName";
244
+                $query = "SELECT * FROM $tableName WHERE $columnName";
245 245
             }
246
-        } catch ( PDOException $e ) {
246
+        } catch (PDOException $e) {
247 247
             $query = $e->getMessage();
248 248
         }
249 249
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function insertQuery($tableName)
259 259
     {
260
-        $data = ( array )$this;
260
+        $data = (array)$this;
261 261
         array_shift($data);
262 262
 
263 263
         $columnNames = self::buildColumn($data);
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
      */
275 275
     public function updateQuery($tableName)
276 276
     {
277
-        $data = ( array ) $this;
278
-        $data = array_slice ($data, 2);
277
+        $data = (array)$this;
278
+        $data = array_slice($data, 2);
279 279
 
280 280
         $values = self::buildClause($tableName, $data);
281
-        $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ". self::sanitize($this->id);
281
+        $updateQuery = "UPDATE $tableName SET {$values} WHERE id = ".self::sanitize($this->id);
282 282
 
283 283
         return $updateQuery;
284 284
     }
Please login to merge, or discard this patch.