Completed
Push — develop ( 6a89b9...3f7eb4 )
by Oyebanji Jacob
08:06 queued 05:44
created
src/Model.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -152,17 +152,17 @@  discard block
 block discarded – undo
152 152
     public function update()
153 153
     {
154 154
         $bindNameParameters = [];
155
-        $sqlUpdate = 'UPDATE '.$this->getTableName().' SET ';
155
+        $sqlUpdate = 'UPDATE ' . $this->getTableName() . ' SET ';
156 156
         foreach ($this->properties as $columnName => $columnValue) {
157 157
             if ($columnName == 'id') {
158 158
                 continue;
159 159
             }
160
-            $bindColumnName = ':'.$columnName;
160
+            $bindColumnName = ':' . $columnName;
161 161
             $sqlUpdate .= "$columnName = $bindColumnName,";
162 162
             $bindNameParameters[$bindColumnName] = $columnValue;
163 163
         }
164 164
         //Remove the last comma in sql command then join it to the other query part.
165
-        $sqlUpdate = substr($sqlUpdate, 0, -1).' WHERE id = :id';
165
+        $sqlUpdate = substr($sqlUpdate, 0, -1) . ' WHERE id = :id';
166 166
         $sqlStatement = $this->databaseConnection->prepare($sqlUpdate);
167 167
         $bindNameParameters[':id'] = $this->properties['id'];
168 168
         $sqlStatement->execute($bindNameParameters);
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
         $columnNames = '';
181 181
         $columnValues = '';
182 182
         $bindNameParameters = [];
183
-        $sqlCreate = 'INSERT'.' INTO '.$this->getTableName().' (';
183
+        $sqlCreate = 'INSERT' . ' INTO ' . $this->getTableName() . ' (';
184 184
         foreach ($this->properties as $columnName => $columnValue) {
185
-            $bindColumnName = ':'.$columnName;
186
-            $columnNames .= $columnName.',';
187
-            $columnValues .= $bindColumnName.',';
185
+            $bindColumnName = ':' . $columnName;
186
+            $columnNames .= $columnName . ',';
187
+            $columnValues .= $bindColumnName . ',';
188 188
             $bindNameParameters[$bindColumnName] = $columnValue;
189 189
         }
190 190
         // Remove ending comma and whitespace.
191 191
         $columnNames = substr($columnNames, 0, -1);
192 192
         $columnValues = substr($columnValues, 0, -1);
193 193
 
194
-        $sqlCreate .= $columnNames.') VALUES ('.$columnValues.')';
194
+        $sqlCreate .= $columnNames . ') VALUES (' . $columnValues . ')';
195 195
         $sqlStatement = $this->databaseConnection->prepare($sqlCreate);
196 196
         $sqlStatement->execute($bindNameParameters);
197 197
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public function delete($id)
233 233
     {
234
-        $sql = 'DELETE'.' FROM '.self::getTableName().' WHERE id = '.$id;
234
+        $sql = 'DELETE' . ' FROM ' . self::getTableName() . ' WHERE id = ' . $id;
235 235
         $sqlStatment = $this->databaseConnection->prepare($sql);
236 236
         $sqlStatment->execute();
237 237
 
Please login to merge, or discard this patch.
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -24,23 +24,23 @@  discard block
 block discarded – undo
24 24
      */
25 25
     protected $databaseConnection;
26 26
 
27
-     /**
28
-      *  The id of the model.
29
-      *
30
-      * @property string $id
31
-      */
32
-
33
-     /**
34
-      * Create a model instance.
35
-      */
36
-     public function __construct(DatabaseConnectionInterface $databaseConnection = null)
37
-     {
38
-         if ($databaseConnection == null) {
39
-             $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection;
40
-         } else {
41
-             $this->databaseConnection = $databaseConnection;
42
-         }
43
-     }
27
+        /**
28
+         *  The id of the model.
29
+         *
30
+         * @property string $id
31
+         */
32
+
33
+        /**
34
+         * Create a model instance.
35
+         */
36
+        public function __construct(DatabaseConnectionInterface $databaseConnection = null)
37
+        {
38
+            if ($databaseConnection == null) {
39
+                $this->databaseConnection = DatabaseConnection::getInstance()->databaseConnection;
40
+            } else {
41
+                $this->databaseConnection = $databaseConnection;
42
+            }
43
+        }
44 44
 
45 45
     /**
46 46
      * Sets into $properties the $key => $value pairs.
@@ -65,23 +65,23 @@  discard block
 block discarded – undo
65 65
         }
66 66
     }
67 67
 
68
-     /**
69
-      * Get all the model properties.
70
-      *
71
-      * @return array
72
-      */
73
-     public function getProperties()
74
-     {
75
-         return $this->properties;
76
-     }
77
-
78
-     /**
79
-      * Set model properties.
80
-      */
81
-     public function setProperties(array $properties)
82
-     {
83
-         $this->properties = $properties;
84
-     }
68
+        /**
69
+         * Get all the model properties.
70
+         *
71
+         * @return array
72
+         */
73
+        public function getProperties()
74
+        {
75
+            return $this->properties;
76
+        }
77
+
78
+        /**
79
+         * Set model properties.
80
+         */
81
+        public function setProperties(array $properties)
82
+        {
83
+            $this->properties = $properties;
84
+        }
85 85
 
86 86
     /**
87 87
      * Pluralize the name of the child class.
Please login to merge, or discard this patch.