Completed
Push — master ( 62fed0...edf4b9 )
by Adeniyi
8s
created
src/Database/DatabaseQuery.php 5 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,6 @@
 block discarded – undo
13 13
 use PDOException;
14 14
 use Ibonly\PotatoORM\DatabaseQueryInterface;
15 15
 use Ibonly\PotatoORM\ColumnNotExistExeption;
16
-use Ibonly\PotatoORM\InvalidConnectionException;
17 16
 use Ibonly\PotatoORM\TableDoesNotExistException;
18 17
 
19 18
 class DatabaseQuery implements DatabaseQueryInterface
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * This class handles building sql query statement and check
4
- * that the table exist in the database.
5
- *
6
- * @package Ibonly\PotatoORM\DatabaseQuery
7
- * @author  Ibraheem ADENIYI <[email protected]>
8
- * @license MIT <https://opensource.org/licenses/MIT>
9
- */
3
+     * This class handles building sql query statement and check
4
+     * that the table exist in the database.
5
+     *
6
+     * @package Ibonly\PotatoORM\DatabaseQuery
7
+     * @author  Ibraheem ADENIYI <[email protected]>
8
+     * @license MIT <https://opensource.org/licenses/MIT>
9
+     */
10 10
 
11 11
 namespace Ibonly\PotatoORM;
12 12
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -136,8 +136,9 @@  discard block
 block discarded – undo
136 136
         {
137 137
             $counter++;
138 138
             $insertQuery .= self::sanitize($key);
139
-            if( $arraySize > $counter )
140
-                $insertQuery .= ", ";
139
+            if( $arraySize > $counter ) {
140
+                            $insertQuery .= ", ";
141
+            }
141 142
         }
142 143
         return $insertQuery;
143 144
     }
@@ -159,8 +160,9 @@  discard block
 block discarded – undo
159 160
         {
160 161
             $counter++;
161 162
             $insertQuery .= "'".self::sanitize($value) ."'";
162
-            if( $arraySize > $counter )
163
-                $insertQuery .= ", ";
163
+            if( $arraySize > $counter ) {
164
+                            $insertQuery .= ", ";
165
+            }
164 166
         }
165 167
         return $insertQuery;
166 168
     }
@@ -240,8 +242,7 @@  discard block
 block discarded – undo
240 242
             if( $arraySize > 1 && $condition == NULL)
241 243
             {
242 244
                 $query = "Please Supply the condition";
243
-            }
244
-            else
245
+            } else
245 246
             {
246 247
                 $columnName = self::whereAndClause($tableName, $data, $condition);
247 248
                 $query =  "SELECT * FROM $tableName WHERE $columnName";
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param  $tablename
63 63
      * @param  $con
64 64
      *
65
-     * @return bool
65
+     * @return boolean|null
66 66
      */
67 67
     public function checkTableExist($table, $con=NULL)
68 68
     {
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     /**
78 78
      * checkTableName Return the table name
79 79
      *
80
-     * @param  $tablename
80
+     * @param  string|false $tablename
81 81
      * @param  $con
82 82
      *
83 83
      * @return string
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      * checkColumn Check if column exist in table
99 99
      *
100 100
      * @param  $tableName
101
-     * @param  $columnName
101
+     * @param  string $columnName
102 102
      * @param  $con
103 103
      *
104 104
      * @return string
@@ -191,6 +191,8 @@  discard block
 block discarded – undo
191 191
     /**
192 192
      * selectAllQuery
193 193
      *
194
+     * @param string $tableName
195
+     * @param string $field
194 196
      * @return string
195 197
      */
196 198
     public static function selectAllQuery($tableName, $field)
@@ -226,6 +228,9 @@  discard block
 block discarded – undo
226 228
     /**
227 229
      * selectQuery
228 230
      *
231
+     * @param string $tableName
232
+     * @param string $fields
233
+     * @param string $connection
229 234
      * @return string
230 235
      */
231 236
     public static function selectQuery($tableName, $fields, $data, $condition, $connection)
@@ -253,6 +258,7 @@  discard block
 block discarded – undo
253 258
     /**
254 259
      * insertQuery
255 260
      *
261
+     * @param string $tableName
256 262
      * @return string
257 263
      */
258 264
     public function insertQuery($tableName)
@@ -270,6 +276,7 @@  discard block
 block discarded – undo
270 276
     /**
271 277
      * updateQuery
272 278
      *
279
+     * @param string $tableName
273 280
      * @return string
274 281
      */
275 282
     public function updateQuery($tableName)
Please login to merge, or discard this 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 $fields FROM $tableName WHERE $columnName";
244
+                $query = "SELECT $fields 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.
src/Database/DBConfig.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,12 +42,10 @@
 block discarded – undo
42 42
             if ($this->driver === 'pgsql' || $this->driver === 'postgres')
43 43
             {
44 44
                 parent::__construct($this->pgsqlConnectionString());
45
-            }
46
-            elseif ($this->driver === 'mysql')
45
+            } elseif ($this->driver === 'mysql')
47 46
             {
48 47
                 parent::__construct($this->mysqlConnectionString(), $this->user, $this->password);
49
-            }
50
-            elseif($this->driver === 'sqlite')
48
+            } elseif($this->driver === 'sqlite')
51 49
             {
52 50
                 parent::__construct($this->sqlitConnectionString());
53 51
             }
Please login to merge, or discard this 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
- * This class handles database connection.
4
- *
5
- * @package Ibonly\PotatoORM\DBConfig
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * This class handles database connection.
4
+     *
5
+     * @package Ibonly\PotatoORM\DBConfig
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.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             {
48 48
                 parent::__construct($this->mysqlConnectionString(), $this->user, $this->password);
49 49
             }
50
-            elseif($this->driver === 'sqlite')
50
+            elseif ($this->driver === 'sqlite')
51 51
             {
52 52
                 parent::__construct($this->sqlitConnectionString());
53 53
             }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function pgsqlConnectionString()
65 65
     {
66
-        return $this->driver . ':host=' . $this->host . ';port=' . $this->port . ';dbname=' . $this->dbname . ';user=' . $this->user . ';password=' . $this->password;
66
+        return $this->driver.':host='.$this->host.';port='.$this->port.';dbname='.$this->dbname.';user='.$this->user.';password='.$this->password;
67 67
     }
68 68
 
69 69
     /**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     protected function mysqlConnectionString()
75 75
     {
76
-        return $this->driver . ':host=' . $this->host . ';dbname=' . $this->dbname . ';charset=utf8mb4';
76
+        return $this->driver.':host='.$this->host.';dbname='.$this->dbname.';charset=utf8mb4';
77 77
     }
78 78
 
79 79
     /**
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function sqlitConnectionString()
85 85
     {
86
-        return $this->driver . ':' . $this->sqlitePath;
86
+        return $this->driver.':'.$this->sqlitePath;
87 87
     }
88 88
 
89 89
     /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function loadEnv()
93 93
     {
94
-        if( ! getenv("APP_ENV"))
94
+        if ( ! getenv("APP_ENV"))
95 95
         {
96 96
             $dotenv = new Dotenv($_SERVER['DOCUMENT_ROOT']);
97 97
             $dotenv->load();
Please login to merge, or discard this patch.
src/Exceptions/ColumnNotExistExeption.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
- * Exception for user not found
4
- *
5
- * @package Ibonly\PotatoORM\ColumnNotExistExeption
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * Exception for user not found
4
+     *
5
+     * @package Ibonly\PotatoORM\ColumnNotExistExeption
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/Exceptions/ErrorInsertingException.php 2 patches
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
- * Exception for user already exist
4
- *
5
- * @package Ibonly\PotatoORM\ErrorInsertingException
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * Exception for user already exist
4
+     *
5
+     * @package Ibonly\PotatoORM\ErrorInsertingException
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,6 +25,6 @@
 block discarded – undo
25 25
      */
26 26
     public function errorMessage()
27 27
     {
28
-        return "Error: " . $this->getMessage();
28
+        return "Error: ".$this->getMessage();
29 29
     }
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Exceptions/InvalidConnectionException.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
- * Exception for user not found
4
- *
5
- * @package Ibonly\PotatoORM\InvalidConnectionException
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * Exception for user not found
4
+     *
5
+     * @package Ibonly\PotatoORM\InvalidConnectionException
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/Exceptions/TableDoesNotExistException.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
- * Exception for user not found
4
- *
5
- * @package Ibonly\PotatoORM\TableDoesNotExistException
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * Exception for user not found
4
+     *
5
+     * @package Ibonly\PotatoORM\TableDoesNotExistException
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/Inflector.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 trait Inflector
40 40
 {
41 41
     /**
42
-    * Pluralizes English nouns.
43
-    *
44
-    * @access public
45
-    * @static
46
-    * @param    string    $word    English noun to pluralize
47
-    * @return string Plural noun
48
-    */
42
+     * Pluralizes English nouns.
43
+     *
44
+     * @access public
45
+     * @static
46
+     * @param    string    $word    English noun to pluralize
47
+     * @return string Plural noun
48
+     */
49 49
     public static function pluralize($word)
50 50
     {
51 51
         $plural = array(
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
     }
103 103
 
104 104
     /**
105
-    * Singularizes English nouns.
106
-    *
107
-    * @access public
108
-    * @static
109
-    * @param    string    $word    English noun to singularize
110
-    * @return string Singular noun.
111
-    */
105
+     * Singularizes English nouns.
106
+     *
107
+     * @access public
108
+     * @static
109
+     * @param    string    $word    English noun to singularize
110
+     * @return string Singular noun.
111
+     */
112 112
     public function singularize($word)
113 113
     {
114 114
         $singular = array (
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 
82 82
         $lowercased_word = strtolower($word);
83 83
 
84
-        foreach ($uncountable as $_uncountable){
85
-            if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){
84
+        foreach ($uncountable as $_uncountable) {
85
+            if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) {
86 86
                 return $word;
87 87
             }
88 88
         }
89 89
 
90
-        foreach ($irregular as $_plural=> $_singular){
90
+        foreach ($irregular as $_plural=> $_singular) {
91 91
             if (preg_match('/('.$_plural.')$/i', $word, $arr)) {
92
-                return preg_replace('/('.$_plural.')$/i', substr($arr[0],0,1).substr($_singular,1), $word);
92
+                return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1).substr($_singular, 1), $word);
93 93
             }
94 94
         }
95 95
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     */
112 112
     public function singularize($word)
113 113
     {
114
-        $singular = array (
114
+        $singular = array(
115 115
             '/(quiz)zes$/i'             => "$1",
116 116
             '/(matr)ices$/i'            => "$1ix",
117 117
             '/(vert|ind)ices$/i'        => "$1ex",
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
         'move' => 'moves');
153 153
 
154 154
         $lowercased_word = strtolower($word);
155
-        foreach ($uncountable as $_uncountable){
156
-            if(substr($lowercased_word,(-1*strlen($_uncountable))) == $_uncountable){
155
+        foreach ($uncountable as $_uncountable) {
156
+            if (substr($lowercased_word, (-1*strlen($_uncountable))) == $_uncountable) {
157 157
                 return $word;
158 158
             }
159 159
         }
160 160
 
161
-        foreach ($irregular as $_plural=> $_singular){
161
+        foreach ($irregular as $_plural=> $_singular) {
162 162
             if (preg_match('/('.$_singular.')$/i', $word, $arr)) {
163
-                return preg_replace('/('.$_singular.')$/i', substr($arr[0],0,1).substr($_plural,1), $word);
163
+                return preg_replace('/('.$_singular.')$/i', substr($arr[0], 0, 1).substr($_plural, 1), $word);
164 164
             }
165 165
         }
166 166
 
Please login to merge, or discard this patch.
src/Helper/Model.php 4 patches
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
- * PotatoORM manages the persistence of database CRUD operations.
4
- *
5
- * @package Ibonly\PotatoORM\Model
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * PotatoORM manages the persistence of database CRUD operations.
4
+     *
5
+     * @package Ibonly\PotatoORM\Model
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.
Unused Use Statements   -5 removed lines patch added patch discarded remove patch
@@ -9,17 +9,12 @@
 block discarded – undo
9 9
 
10 10
 namespace Ibonly\PotatoORM;
11 11
 
12
-use PDO;
13
-use Exception;
14
-use PDOException;
15 12
 use Ibonly\PotatoORM\GetData;
16 13
 use Ibonly\PotatoORM\DatabaseQuery;
17 14
 use Ibonly\PotatoORM\ModelInterface;
18 15
 use Ibonly\PotatoORM\UserNotFoundException;
19 16
 use Ibonly\PotatoORM\EmptyDatabaseException;
20 17
 use Ibonly\PotatoORM\SaveUserExistException;
21
-use Ibonly\PotatoORM\ColumnNotExistExeption;
22
-use Ibonly\PotatoORM\InvalidConnectionException;
23 18
 
24 19
 class Model extends DatabaseQuery implements ModelInterface
25 20
 {
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,6 +51,7 @@  discard block
 block discarded – undo
51 51
     /**
52 52
      * getTableName()
53 53
      *
54
+     * @param string $connection
54 55
      * @return string
55 56
      */
56 57
     public static function getTableName($connection)
@@ -62,7 +63,7 @@  discard block
 block discarded – undo
62 63
      * getALL()
63 64
      * Get all record from the database
64 65
      *
65
-     * @return object
66
+     * @return GetData
66 67
      */
67 68
     public function getALL($dbConnection = NULL)
68 69
     {
@@ -82,7 +83,7 @@  discard block
 block discarded – undo
82 83
      * where($data, $condition)
83 84
      * Get data from database where $data = $condition
84 85
      *
85
-     * @return object
86
+     * @return GetData
86 87
      */
87 88
     public function where($data, $condition = NULL, $dbConnection = NULL)
88 89
     {
@@ -103,7 +104,7 @@  discard block
 block discarded – undo
103 104
      * find($value)
104 105
      * Find data from database where id = $value
105 106
      *
106
-     * @return array
107
+     * @return Model
107 108
      */
108 109
     public static function find($value, $dbConnection = NULL)
109 110
     {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function tableName()
48 48
     {
49
-        if(isset($this->table)) {
49
+        if (isset($this->table)) {
50 50
             return $this->table;
51 51
         }
52 52
         return null;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $sqlQuery = DatabaseQuery::selectAllQuery(self::getTableName($connection), self::fields());
106 106
         $query = $connection->prepare($sqlQuery);
107 107
         $query->execute();
108
-        if ( $query->rowCount() )
108
+        if ($query->rowCount())
109 109
         {
110 110
             return new GetData($query->fetchAll($connection::FETCH_ASSOC));
111 111
         }
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         $sqlQuery = $databaseQuery->selectQuery(self::getTableName($connection), $data, $condition, $connection);
127 127
         $query = $connection->prepare($sqlQuery);
128 128
         $query->execute();
129
-        if ( $query->rowCount() )
129
+        if ($query->rowCount())
130 130
         {
131 131
             return new GetData($query->fetchAll($connection::FETCH_ASSOC));
132 132
         }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
         $sqlQuery = DatabaseQuery::selectQuery(self::getTableName($connection), ['id' => $value], NULL, $connection);
147 147
         $query = $connection->prepare($sqlQuery);
148 148
         $query->execute();
149
-        if ( $query->rowCount() )
149
+        if ($query->rowCount())
150 150
         {
151 151
             $found = new static;
152 152
             $found->id = $value;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
         $query = $this->insertQuery(self::getTableName($connection));
170 170
         $statement = $connection->prepare($query);
171
-        if( $statement->execute() )
171
+        if ($statement->execute())
172 172
         {
173 173
             return true;
174 174
         }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
         $updateQuery = $this->updateQuery(self::getTableName($connection));
190 190
         $statement = $connection->prepare($updateQuery);
191
-        if( $statement->execute() )
191
+        if ($statement->execute())
192 192
         {
193 193
             return true;
194 194
         }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
     {
206 206
         $connection = DatabaseQuery::checkConnection($dbConnection);
207 207
 
208
-        $query = $connection->prepare('DELETE FROM ' . self::getTableName($connection) . ' WHERE id = '.$value);
208
+        $query = $connection->prepare('DELETE FROM '.self::getTableName($connection).' WHERE id = '.$value);
209 209
         $query->execute();
210 210
         $check = $query->rowCount();
211 211
         if ($check)
Please login to merge, or discard this patch.
src/Helper/Schema.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * SugarORM\Schema manages the creation of database table.
4
- *
5
- * @package Ibonly\SugarORM\Schema
6
- * @author  Ibraheem ADENIYI <[email protected]>
7
- * @license MIT <https://opensource.org/licenses/MIT>
8
- */
3
+     * SugarORM\Schema manages the creation of database table.
4
+     *
5
+     * @package Ibonly\SugarORM\Schema
6
+     * @author  Ibraheem ADENIYI <[email protected]>
7
+     * @license MIT <https://opensource.org/licenses/MIT>
8
+     */
9 9
 
10 10
 namespace Ibonly\PotatoORM;
11 11
 
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
     public function field($type, $fieldName, $length=NULL)
29 29
     {
30 30
         if(is_null($length)){
31
-             $this->fieldDescription[] = $type ." ".$fieldName;
31
+                $this->fieldDescription[] = $type ." ".$fieldName;
32 32
         }else
33 33
         {
34
-         $this->fieldDescription[] = $type ." ".$fieldName." ".$length;
34
+            $this->fieldDescription[] = $type ." ".$fieldName." ".$length;
35 35
         }
36 36
 
37 37
     }
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     {
30 30
         if(is_null($length)){
31 31
              $this->fieldDescription[] = $type ." ".$fieldName;
32
-        }else
32
+        } else
33 33
         {
34 34
          $this->fieldDescription[] = $type ." ".$fieldName." ".$length;
35 35
         }
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             if(sizeof($e) == 2)
53 53
             {
54 54
                 $query .= $this->$e[0]($e[1], 20) .", ".PHP_EOL;
55
-            }else
55
+            } else
56 56
             {
57 57
                     $query .= $this->$e[0]($e[1], $e[2]) .", ".PHP_EOL;
58 58
             }
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
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
     }
Please login to merge, or discard this 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.