Passed
Push — master ( 620cae...c5a08c )
by Henri
01:20
created
src/Connect.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
14 14
         if (empty(self::$instance)) {
15 15
             try {
16 16
 
17
-                if(!defined('DATAMANAGER_CONFIG')){
17
+                if (!defined('DATAMANAGER_CONFIG')) {
18 18
                     throw new Exception("Information for connection to the database not defined.");
19 19
                 }
20 20
 
21 21
                 self::$instance = new PDO(
22
-                    DATAMANAGER_CONFIG['driver'] . ':host='.DATAMANAGER_CONFIG['host'] . ';port='.DATAMANAGER_CONFIG['port'] . ';dbname='.DATAMANAGER_CONFIG['database'] . ';charset='.DATAMANAGER_CONFIG['charset'],
22
+                    DATAMANAGER_CONFIG['driver'].':host='.DATAMANAGER_CONFIG['host'].';port='.DATAMANAGER_CONFIG['port'].';dbname='.DATAMANAGER_CONFIG['database'].';charset='.DATAMANAGER_CONFIG['charset'],
23 23
                     DATAMANAGER_CONFIG['username'],
24 24
                     DATAMANAGER_CONFIG['password'],
25 25
                     DATAMANAGER_CONFIG['options']
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         return self::$instance;
32 32
     }
33 33
 
34
-    public static function destroy(){
34
+    public static function destroy() {
35 35
         self::$instance = null;
36 36
     }
37 37
 
Please login to merge, or discard this patch.
examples/Models/User.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@
 block discarded – undo
5 5
 use HnrAzevedo\Datamanager\Datamanager;
6 6
 
7 7
 /** 
8
-  * @property string $name 
9
-  * @property string $email 
10
-  * @property string $password
11
-  */ 
8
+ * @property string $name 
9
+ * @property string $email 
10
+ * @property string $password
11
+ */ 
12 12
 class User extends Datamanager{
13 13
 
14 14
     public function __construct()
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
   * @property string $email 
10 10
   * @property string $password
11 11
   */ 
12
-class User extends Datamanager{
12
+class User extends Datamanager {
13 13
 
14 14
     public function __construct()
15 15
     {
16
-        parent::create('user','id');
16
+        parent::create('user', 'id');
17 17
     }
18 18
 
19 19
 }
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
src/CrudTrait.php 3 patches
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
             $stmt = Connect::getInstance()->prepare("{$query}");
34 34
             $stmt->execute($data);
35 35
             return $stmt->fetchAll(PDO::FETCH_ASSOC);
36
-        }catch(Exception $exception){
36
+        } catch(Exception $exception){
37 37
             $this->fail = $exception;
38 38
         }
39 39
         return [];
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
             $stmt = Connect::getInstance()->prepare("DESCRIBE {$this->table}");
46 46
             $stmt->execute();
47 47
             return $stmt->fetchAll(PDO::FETCH_ASSOC);
48
-        }catch(Exception $exception){
48
+        } catch(Exception $exception){
49 49
             $this->fail = $exception;
50 50
             return [];
51 51
         }
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
         }
25 25
 
26 26
         if(!Connect::getInstance()->inTransaction()){
27
-           return Connect::getInstance()->beginTransaction();
27
+            return Connect::getInstance()->beginTransaction();
28 28
         }
29 29
 
30 30
         switch ($transaction) {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -6,24 +6,24 @@  discard block
 block discarded – undo
6 6
 use PDOException;
7 7
 use PDO;
8 8
 
9
-trait CrudTrait{
9
+trait CrudTrait {
10 10
 
11 11
     protected ?Exception $fail = null;
12 12
 
13 13
     protected function check_fail()
14 14
     {
15
-        if(!is_null($this->fail)){
15
+        if (!is_null($this->fail)) {
16 16
             throw $this->fail;
17 17
         }
18 18
     }
19 19
 
20 20
     protected function transaction(string $transaction): ?bool
21 21
     {
22
-        if(array_key_exists($transaction,['begin','commit','rollback'])){
22
+        if (array_key_exists($transaction, ['begin', 'commit', 'rollback'])) {
23 23
             throw new Exception("{$transaction} é um estado inválido para transações.");
24 24
         }
25 25
 
26
-        if(!Connect::getInstance()->inTransaction()){
26
+        if (!Connect::getInstance()->inTransaction()) {
27 27
            return Connect::getInstance()->beginTransaction();
28 28
         }
29 29
 
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
         return false;
35 35
     }
36 36
 
37
-    protected function select(string $query,array $data): ?array
37
+    protected function select(string $query, array $data): ?array
38 38
     {
39
-        try{
39
+        try {
40 40
             $stmt = Connect::getInstance()->prepare("{$query}");
41 41
             $stmt->execute($data);
42 42
             return $stmt->fetchAll(PDO::FETCH_ASSOC);
43
-        }catch(Exception $exception){
43
+        } catch (Exception $exception) {
44 44
             $this->fail = $exception;
45 45
         }
46 46
         return [];
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 
49 49
     protected function describe(): array
50 50
     {
51
-        try{
51
+        try {
52 52
             $stmt = Connect::getInstance()->prepare("DESCRIBE {$this->table}");
53 53
             $stmt->execute();
54 54
             return $stmt->fetchAll(PDO::FETCH_ASSOC);
55
-        }catch(Exception $exception){
55
+        } catch (Exception $exception) {
56 56
             $this->fail = $exception;
57 57
             return [];
58 58
         }
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         try {
64 64
             $columns = implode(", ", array_keys($data));
65
-            $values = ":" . implode(", :", array_keys($data));
65
+            $values = ":".implode(", :", array_keys($data));
66 66
 
67 67
             $stmt = Connect::getInstance()->prepare("INSERT INTO {$this->table} ({$columns}) VALUES ({$values})");
68 68
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         try {
101 101
             $stmt = Connect::getInstance()->prepare("DELETE FROM {$this->table} WHERE {$terms}");
102 102
 
103
-            if($params){
103
+            if ($params) {
104 104
                 parse_str($params, $arr);
105 105
                 $stmt->execute($arr);
106 106
                 return true;
Please login to merge, or discard this patch.
examples/index.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 $entity = new User();
12 12
 
13
-try{
13
+try {
14 14
     /* Set new info for insert in database */
15 15
     $entity->name = 'Henri Azevedo';
16 16
     $entity->email = '[email protected]';
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     $user = $entity->find()->execute()->first()->toEntity();
24 24
 
25 25
     /* Search only for columns defined in advance  */
26
-    $user = $entity->find()->only(['name','email'])->execute()->first();
26
+    $user = $entity->find()->only(['name', 'email'])->execute()->first();
27 27
     $name = $user->name;
28 28
     $email = $user->email;
29 29
     /* OR */
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 
44 44
     /* Remove by cause *Where* */
45 45
     $user->remove()->where([
46
-        ['name','=','Other Name'],
47
-        'OR' => ['email','LIKE','[email protected]']
46
+        ['name', '=', 'Other Name'],
47
+        'OR' => ['email', 'LIKE', '[email protected]']
48 48
     ])->execute();
49
-}catch(Exception $er){
49
+} catch (Exception $er) {
50 50
 
51 51
     die("Code Error: {$er->getCode()}, Line: {$er->getLine()}, File: {$er->getFile()}, Message: {$er->getMessage()}.");
52 52
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
         ['name','=','Other Name'],
47 47
         'OR' => ['email','LIKE','[email protected]']
48 48
     ])->execute();
49
-}catch(Exception $er){
49
+} catch(Exception $er){
50 50
 
51 51
     die("Code Error: {$er->getCode()}, Line: {$er->getLine()}, File: {$er->getFile()}, Message: {$er->getMessage()}.");
52 52
 
Please login to merge, or discard this patch.
src/Datamanager.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
             $this->check_fail();
138 138
 
139 139
             $this->transaction('commit');
140
-        }catch(Exception $er){
140
+        } catch(Exception $er){
141 141
             $this->transaction('rollback');
142 142
             throw $er;
143 143
         }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
     
11 11
     
12 12
 
13
-    private array $where = [''=> ["1",'=',"1"] ];
13
+    private array $where = [''=> ["1", '=', "1"]];
14 14
 
15 15
     private function mountTable_Field(string $field, $value = null)
16 16
     {
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
         $type = $value;
23 23
         $maxlength = null;
24 24
 
25
-        if(strpos($value,'(')){
26
-            $type = (in_array( substr($value, 0, strpos($value,'(')) , ['varchar','char','text'])) ? 'string' : $type;
27
-            $type = (in_array( substr($value, 0, strpos($value,'(')) , ['tinyint','mediumint','smallint','bigtint','int'])) ? 'int' : $type;
28
-            $type = (in_array( substr($value, 0, strpos($value,'(')) , ['decimal','float','double','real'])) ? 'float' : $type;
25
+        if (strpos($value, '(')) {
26
+            $type = (in_array(substr($value, 0, strpos($value, '(')), ['varchar', 'char', 'text'])) ? 'string' : $type;
27
+            $type = (in_array(substr($value, 0, strpos($value, '(')), ['tinyint', 'mediumint', 'smallint', 'bigtint', 'int'])) ? 'int' : $type;
28
+            $type = (in_array(substr($value, 0, strpos($value, '(')), ['decimal', 'float', 'double', 'real'])) ? 'float' : $type;
29 29
         }
30 30
 
31
-        $maxlength = (in_array( $type , ['string','float','int'])) ? substr($value,(strpos($value,'(')+1),-1) : $maxlength;
32
-        $maxlength = (in_array( $type , ['date'])) ? 10 : $maxlength;
33
-        $maxlength = (in_array( $type , ['datetime'])) ? 19 : $maxlength;
34
-        $maxlength = (in_array( $type , ['boolean'])) ? 1 : $maxlength;
31
+        $maxlength = (in_array($type, ['string', 'float', 'int'])) ? substr($value, (strpos($value, '(') + 1), -1) : $maxlength;
32
+        $maxlength = (in_array($type, ['date'])) ? 10 : $maxlength;
33
+        $maxlength = (in_array($type, ['datetime'])) ? 19 : $maxlength;
34
+        $maxlength = (in_array($type, ['boolean'])) ? 1 : $maxlength;
35 35
 
36 36
         $this->$field = ['maxlength' => $maxlength];
37 37
         $this->$field = ['type' => $type];
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
 
75 75
     public function check_where_array(array $where)
76 76
     {
77
-        if(count($where) != 3){
78
-            throw new Exception("Condition where set incorrectly: ".implode(' ',$where));
77
+        if (count($where) != 3) {
78
+            throw new Exception("Condition where set incorrectly: ".implode(' ', $where));
79 79
         }
80 80
 
81
-        if(!array_key_exists($where[0],$this->data) && $this->full){
81
+        if (!array_key_exists($where[0], $this->data) && $this->full) {
82 82
             throw new Exception("{$where[0]} field does not exist in the table {$this->table}.");
83 83
         }
84 84
     }
@@ -86,14 +86,14 @@  discard block
 block discarded – undo
86 86
     private function mountRemove(): array
87 87
     {
88 88
         $return = ['data' => [], 'where' => ''];
89
-        foreach($this->where as $clause => $condition){
90
-            if(strlen($clause) === 0){
89
+        foreach ($this->where as $clause => $condition) {
90
+            if (strlen($clause) === 0) {
91 91
                 $return['where'] .= " {$clause} {$condition[0]} {$condition[1]} :q_{$condition[0]} ";
92 92
                 $return['data'] .= "q_{$condition[0]}={$condition[2]}&";
93 93
                 continue;
94 94
             }
95 95
                 
96
-            foreach($condition as $value){
96
+            foreach ($condition as $value) {
97 97
                 $return['where'] .= " {$clause} {$value[0]} {$value[1]} :q_{$value[0]} ";
98 98
                 $return['data'] .= "q_{$value[0]}={$value[2]}&";
99 99
             }
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
         $return = ['data' => []];
107 107
 
108 108
         foreach ($this->data as $key => $value) {
109
-            if(strstr($this->data[$key]['extra'],'auto_increment') && $key !== $this->primary){
109
+            if (strstr($this->data[$key]['extra'], 'auto_increment') && $key !== $this->primary) {
110 110
                 continue;
111 111
             }
112 112
 
113
-            if(($this->data[$key]['changed'] && $this->data[$key]['upgradeable']) || $this->primary === $key){
113
+            if (($this->data[$key]['changed'] && $this->data[$key]['upgradeable']) || $this->primary === $key) {
114 114
                 $return['data'][$key] = $this->data[$key]['value'];
115 115
             }
116 116
         }
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         $this->transaction('begin');
124 124
 
125
-        try{
125
+        try {
126 126
             $this->update(
127 127
                 $this->mountSave()['data'],
128 128
                 "{$this->primary}=:{$this->primary}", 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             $this->check_fail();
133 133
 
134 134
             $this->transaction('commit');
135
-        }catch(Exception $er){
135
+        } catch (Exception $er) {
136 136
             $this->transaction('rollback');
137 137
             throw $er;
138 138
         }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
             $key = (!$key) ? '' : " {$key} ";
150 150
 
151
-            if(is_array($value[0])){
151
+            if (is_array($value[0])) {
152 152
 
153 153
                 foreach ($value as $k => $v) {
154 154
                     $return['where'] .= " {$key} {$v[0]} {$v[1]} :q_{$v[0]} ";
@@ -167,21 +167,21 @@  discard block
 block discarded – undo
167 167
 
168 168
     private function mountSelect()
169 169
     {
170
-        $select = implode(',',array_keys($this->select));
170
+        $select = implode(',', array_keys($this->select));
171 171
 
172
-        $this->query = str_replace('*', $select,$this->query);
172
+        $this->query = str_replace('*', $select, $this->query);
173 173
     }
174 174
 
175 175
     private function mountLimit()
176 176
     {
177
-        if(!is_null($this->limit)){
177
+        if (!is_null($this->limit)) {
178 178
             $this->query .= " LIMIT {$this->limit}";
179 179
         }
180 180
     }
181 181
 
182 182
     private function mountOffset()
183 183
     {
184
-        if(!is_null($this->offset)){
184
+        if (!is_null($this->offset)) {
185 185
             $this->query .= " OFFSET {$this->offset}";
186 186
         }
187 187
     }
Please login to merge, or discard this patch.
src/DataTrait.php 2 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -266,7 +266,7 @@
 block discarded – undo
266 266
             
267 267
             $this->transaction('commit');
268 268
 
269
-        }catch(Exception $er){
269
+        } catch(Exception $er){
270 270
             $this->transaction('rollback');
271 271
             throw $er;
272 272
         }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Exception;
6 6
 
7
-trait DataTrait{
7
+trait DataTrait {
8 8
     protected ?string $table = null;
9 9
     protected ?string $primary = null;
10 10
 
@@ -34,16 +34,16 @@  discard block
 block discarded – undo
34 34
         return $this;
35 35
     }
36 36
 
37
-    public function __set(string $prop,$value)
37
+    public function __set(string $prop, $value)
38 38
     {
39 39
 
40
-        if(is_array($value)){
40
+        if (is_array($value)) {
41 41
             $attr = array_keys($value)[0];
42 42
             $this->data[$prop][$attr] = $value[$attr];
43 43
             return $this;
44 44
         }
45 45
 
46
-        if($this->full && !array_key_exists($prop,$this->data)){
46
+        if ($this->full && !array_key_exists($prop, $this->data)) {
47 47
             throw new Exception("{$prop} field does not exist in the table {$this->table}.");
48 48
         }
49 49
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 
61 61
     public function __get(string $field)
62 62
     {
63
-        if($this->full && !array_key_exists($field,$this->data)){
63
+        if ($this->full && !array_key_exists($field, $this->data)) {
64 64
             throw new Exception("{$field} field does not exist in the table {$this->table}.");
65 65
         }
66 66
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $deniable = (is_array($deniable)) ? $deniable : [$deniable];
78 78
 
79 79
         foreach ($deniable as $field) {
80
-            if(!array_key_exists($field,$this->data)){
80
+            if (!array_key_exists($field, $this->data)) {
81 81
                 throw new Exception("{$field} field does not exist in the table {$this->table}.");
82 82
             }
83 83
 
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 
98 98
     public function orderBy(string $field, string $ord = 'ASC')
99 99
     {
100
-        if(!array_key_exists(str_replace(['asc','ASC','desc','DESC',' '],'',$field),$this->data) && $this->full){
100
+        if (!array_key_exists(str_replace(['asc', 'ASC', 'desc', 'DESC', ' '], '', $field), $this->data) && $this->full) {
101 101
             throw new Exception("{$field} field does not exist in the table {$this->table}.");
102 102
         }
103 103
 
104
-        if(strpos(strtolower($field),'asc') || strpos(strtolower($field),'desc')){
104
+        if (strpos(strtolower($field), 'asc') || strpos(strtolower($field), 'desc')) {
105 105
             $ord = '';
106 106
         }
107 107
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
         foreach ($params as $field) {
118 118
 
119
-            if(!array_key_exists($field,$this->data) && $this->full){
119
+            if (!array_key_exists($field, $this->data) && $this->full) {
120 120
                 throw new Exception("{$field} field does not exist in the table {$this->table}.");
121 121
             }
122 122
 
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 
130 130
     public function where(array $where)
131 131
     {
132
-        $this->where['AND'] = (array_key_exists('AND',$this->where)) ?? '';
132
+        $this->where['AND'] = (array_key_exists('AND', $this->where)) ?? '';
133 133
         $w = [];
134 134
         foreach ($where as $condition => $values) {
135 135
 
136
-            if(!is_array($values)){
136
+            if (!is_array($values)) {
137 137
                 $w['AND'][] = $values;
138 138
                 continue;
139 139
             }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
                        
145 145
         }
146 146
 
147
-        $this->where = array_merge($this->where,$w);
147
+        $this->where = array_merge($this->where, $w);
148 148
 
149 149
         return $this;
150 150
     }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
     public function offset(int $offset)
159 159
     {
160
-        if(is_null($this->limit)){
160
+        if (is_null($this->limit)) {
161 161
             throw new Exception("The limit must be set before the offset.");
162 162
         }
163 163
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
         foreach ($arrayValues as $key => $value) {
189 189
 
190
-            if(!array_key_exists($key,$this->data)){
190
+            if (!array_key_exists($key, $this->data)) {
191 191
                 throw new Exception("{$key} field does not exist in the table {$this->table}.");
192 192
             }
193 193
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
         $string = '';
202 202
         foreach ($this->data as $key => $value) {
203 203
 
204
-            if(gettype($value)==='object'){
204
+            if (gettype($value) === 'object') {
205 205
                 $value = $value->getData()[$this->primary]['value'];
206 206
             }
207 207
 
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 
213 213
     public function remove(?bool $exec = false)
214 214
     {
215
-        if(!$exec){
215
+        if (!$exec) {
216 216
             $this->clause = 'remove';    
217 217
             return $this;
218 218
         }
219 219
 
220 220
         $this->clause = null;
221 221
 
222
-        if(count($this->where) == 1){
222
+        if (count($this->where) == 1) {
223 223
             $this->removeById();
224 224
             return $this;
225 225
         }
226 226
 
227
-        $this->delete($this->mountRemove()['where'], substr( $this->mountRemove()['data'] ,0,-1) );
227
+        $this->delete($this->mountRemove()['where'], substr($this->mountRemove()['data'], 0, -1));
228 228
 
229 229
         $this->check_fail();
230 230
             
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
     private function removeById(): bool
235 235
     {
236
-        $delete = $this->delete("{$this->primary}=:{$this->primary}","{$this->primary}={$this->getData()[$this->primary]['value']}");
236
+        $delete = $this->delete("{$this->primary}=:{$this->primary}", "{$this->primary}={$this->getData()[$this->primary]['value']}");
237 237
 
238 238
         $this->check_fail();
239 239
 
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
         $data = [];
248 248
 
249 249
         foreach ($this->data as $key => $value) {
250
-            if(strstr($this->data[$key]['extra'],'auto_increment')){
250
+            if (strstr($this->data[$key]['extra'], 'auto_increment')) {
251 251
                 continue;
252 252
             }
253 253
 
254
-            if(strlen($value['value']) > $value['maxlength']){
254
+            if (strlen($value['value']) > $value['maxlength']) {
255 255
                 throw new Exception("The information provided for column {$key} of table {$this->table} exceeded that allowed.");
256 256
             }
257 257
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         }
262 262
 
263 263
         $this->transaction('begin');
264
-        try{
264
+        try {
265 265
            
266 266
             $id = $this->insert($data);
267 267
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
             
272 272
             $this->transaction('commit');
273 273
 
274
-        }catch(Exception $er){
274
+        } catch (Exception $er) {
275 275
             $this->transaction('rollback');
276 276
             throw $er;
277 277
         }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 
282 282
     public function toEntity()
283 283
     {
284
-        if($this->getCount() === 0){
284
+        if ($this->getCount() === 0) {
285 285
             return null;
286 286
         }
287 287
 
288 288
         $entity = $this->setByDatabase($this->result[0]);
289 289
 
290
-        if(count($this->result) > 1){
290
+        if (count($this->result) > 1) {
291 291
             $entity = [];
292 292
             foreach ($this->result as $key => $value) {
293 293
                 $entity[] = $this->setByDatabase($value);
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 
300 300
     public function findById($id)
301 301
     {
302
-        $this->where([$this->primary,'=',$id]);
302
+        $this->where([$this->primary, '=', $id]);
303 303
         return $this;
304 304
     }
305 305
 
306 306
     public function execute()
307 307
     {
308
-        if(!is_null($this->clause) && $this->clause == 'remove'){
308
+        if (!is_null($this->clause) && $this->clause == 'remove') {
309 309
             return $this->remove(true);
310 310
         }
311 311
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         
314 314
         $this->mountSelect();
315 315
         
316
-        $where = substr($this->mountWhereExec()['where'],0,-1);
316
+        $where = substr($this->mountWhereExec()['where'], 0, -1);
317 317
         $this->query .= " WHERE {$where} ";
318 318
 
319 319
         $this->query .= $this->order;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
     {
336 336
         $this->query = " SELECT * FROM {$this->table} ";
337 337
 
338
-        if(is_int($key)){
338
+        if (is_int($key)) {
339 339
             return $this->findById($key);
340 340
         }
341 341
 
Please login to merge, or discard this patch.