Passed
Push — master ( ae9656...8b853b )
by Henri
01:13
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
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     private bool $full = false;
15 15
     private ?string $clause = null;
16 16
 
17
-    private array $where = [''=> ["1",'=',"1"] ];
17
+    private array $where = [''=> ["1", '=', "1"]];
18 18
     
19 19
 
20 20
     private function mountTable_Field(string $field, $value = null)
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
         $type = $value;
28 28
         $maxlength = null;
29 29
 
30
-        if(strpos($value,'(')){
31
-            $type = (array_key_exists( substr($value,0,strpos($value,'(')) , ['varchar','char','text'])) ? 'string' : $type;
32
-            $type = (array_key_exists( substr($value,0,strpos($value,'(')) , ['tinyint','mediumint','smallint','bigtint','int'])) ? 'int' : $type;
33
-            $type = (array_key_exists( substr($value,0,strpos($value,'(')) , ['decimal','float','double','real'])) ? 'float' : $type;
30
+        if (strpos($value, '(')) {
31
+            $type = (array_key_exists(substr($value, 0, strpos($value, '(')), ['varchar', 'char', 'text'])) ? 'string' : $type;
32
+            $type = (array_key_exists(substr($value, 0, strpos($value, '(')), ['tinyint', 'mediumint', 'smallint', 'bigtint', 'int'])) ? 'int' : $type;
33
+            $type = (array_key_exists(substr($value, 0, strpos($value, '(')), ['decimal', 'float', 'double', 'real'])) ? 'float' : $type;
34 34
         }
35 35
 
36
-        $maxlength = (array_key_exists( $type , ['string','float','int'])) ? substr($value,(strpos($value,'(')+1),-1) : $maxlength;
37
-        $maxlength = (array_key_exists( $type , ['date'])) ? 10 : $maxlength;
38
-        $maxlength = (array_key_exists( $type , ['datetime'])) ? 19 : $maxlength;
39
-        $maxlength = (array_key_exists( $type , ['boolean'])) ? 1 : $maxlength;
36
+        $maxlength = (array_key_exists($type, ['string', 'float', 'int'])) ? substr($value, (strpos($value, '(') + 1), -1) : $maxlength;
37
+        $maxlength = (array_key_exists($type, ['date'])) ? 10 : $maxlength;
38
+        $maxlength = (array_key_exists($type, ['datetime'])) ? 19 : $maxlength;
39
+        $maxlength = (array_key_exists($type, ['boolean'])) ? 1 : $maxlength;
40 40
 
41 41
         $this->$field = ['maxlength' => $maxlength];
42 42
         $this->$field = ['type' => $type];
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 
80 80
     public function check_where_array(array $where)
81 81
     {
82
-        if(count($where) != 3){
83
-            throw new Exception("Condition where set incorrectly: ".implode(' ',$where));
82
+        if (count($where) != 3) {
83
+            throw new Exception("Condition where set incorrectly: ".implode(' ', $where));
84 84
         }
85 85
 
86
-        if(!array_key_exists($where[0],$this->data) && $this->full){
86
+        if (!array_key_exists($where[0], $this->data) && $this->full) {
87 87
             throw new Exception("{$where[0]} field does not exist in the table {$this->table}.");
88 88
         }
89 89
     }
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
     private function mountRemove(): array
92 92
     {
93 93
         $return = ['data' => [], 'where' => []];
94
-        foreach($this->where as $clause => $condition){
95
-            if(strlen($clause) === 0){
94
+        foreach ($this->where as $clause => $condition) {
95
+            if (strlen($clause) === 0) {
96 96
                 $return['where'] .= " {$clause} {$condition[0]} {$condition[1]} :q_{$condition[0]} ";
97 97
                 $return['data'] .= "q_{$condition[0]}={$condition[2]}&";
98 98
                 continue;
99 99
             }
100 100
                 
101
-            foreach($condition as $value){
101
+            foreach ($condition as $value) {
102 102
                 $return['where'] .= " {$clause} {$value[0]} {$value[1]} :q_{$value[0]} ";
103 103
                 $return['data'] .= "q_{$value[0]}={$value[2]}&";
104 104
             }
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
         $return = ['data' => []];
112 112
 
113 113
         foreach ($this->data as $key => $value) {
114
-            if(strstr($this->data[$key]['extra'],'auto_increment') && $key !== $this->primary){
114
+            if (strstr($this->data[$key]['extra'], 'auto_increment') && $key !== $this->primary) {
115 115
                 continue;
116 116
             }
117 117
 
118
-            if(($this->data[$key]['changed'] && $this->data[$key]['upgradeable']) || $this->primary === $key){
118
+            if (($this->data[$key]['changed'] && $this->data[$key]['upgradeable']) || $this->primary === $key) {
119 119
                 $return['data'][$key] = $this->data[$key]['value'];
120 120
             }
121 121
         }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $this->transaction('begin');
129 129
 
130
-        try{
130
+        try {
131 131
             $this->update(
132 132
                 $this->mountSave()['data'],
133 133
                 "{$this->primary}=:{$this->primary}", 
@@ -137,7 +137,7 @@  discard block
 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
         }
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 
154 154
             $key = (!$key) ? '' : " {$key} ";
155 155
 
156
-            if(is_array($value[0])){
156
+            if (is_array($value[0])) {
157 157
 
158 158
                 foreach ($value as $k => $v) {
159 159
                     $return['where'] .= " {$key} {$v[0]} {$v[1]} :q_{$v[0]} ";
@@ -172,21 +172,21 @@  discard block
 block discarded – undo
172 172
 
173 173
     private function mountSelect()
174 174
     {
175
-        $select = implode(',',array_keys($this->select));
175
+        $select = implode(',', array_keys($this->select));
176 176
 
177
-        $this->query = str_replace('*', $select,$this->query);
177
+        $this->query = str_replace('*', $select, $this->query);
178 178
     }
179 179
 
180 180
     private function mountLimit()
181 181
     {
182
-        if(!is_null($this->limit)){
182
+        if (!is_null($this->limit)) {
183 183
             $this->query .= " LIMIT {$this->limit}";
184 184
         }
185 185
     }
186 186
 
187 187
     private function mountOffset()
188 188
     {
189
-        if(!is_null($this->offset)){
189
+        if (!is_null($this->offset)) {
190 190
             $this->query .= " OFFSET {$this->offset}";
191 191
         }
192 192
     }
Please login to merge, or discard this patch.
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.
src/DataTrait.php 2 patches
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
 
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
         return $this;
30 30
     }
31 31
 
32
-    public function __set(string $prop,$value): Datamanager
32
+    public function __set(string $prop, $value): Datamanager
33 33
     {
34 34
 
35
-        if(is_array($value)){
35
+        if (is_array($value)) {
36 36
             $attr = array_keys($value)[0];
37 37
             $this->data[$prop][$attr] = $value[$attr];
38 38
             return $this;
39 39
         }
40 40
 
41
-        if($this->full && !array_key_exists($prop,$this->data)){
41
+        if ($this->full && !array_key_exists($prop, $this->data)) {
42 42
             throw new Exception("{$prop} field does not exist in the table {$this->table}.");
43 43
         }
44 44
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     public function __get(string $field)
57 57
     {
58
-        if($this->full && !array_key_exists($field,$this->data)){
58
+        if ($this->full && !array_key_exists($field, $this->data)) {
59 59
             throw new Exception("{$field} field does not exist in the table {$this->table}.");
60 60
         }
61 61
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
         $deniable = (is_array($deniable)) ? $deniable : [$deniable];
73 73
 
74 74
         foreach ($deniable as $field) {
75
-            if(!array_key_exists($field,$this->data)){
75
+            if (!array_key_exists($field, $this->data)) {
76 76
                 throw new Exception("{$field} field does not exist in the table {$this->table}.");
77 77
             }
78 78
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 
93 93
     public function orderBy(string $field, string $ord = 'ASC'): Datamanager
94 94
     {
95
-        if(!array_key_exists(str_replace(['asc','ASC','desc','DESC',' '],'',$field),$this->data) && $this->full){
95
+        if (!array_key_exists(str_replace(['asc', 'ASC', 'desc', 'DESC', ' '], '', $field), $this->data) && $this->full) {
96 96
             throw new Exception("{$field} field does not exist in the table {$this->table}.");
97 97
         }
98 98
 
99
-        if(strpos(strtolower($field),'asc') || strpos(strtolower($field),'desc')){
99
+        if (strpos(strtolower($field), 'asc') || strpos(strtolower($field), 'desc')) {
100 100
             $ord = '';
101 101
         }
102 102
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
         foreach ($params as $field) {
113 113
 
114
-            if(!array_key_exists($field,$this->data) && $this->full){
114
+            if (!array_key_exists($field, $this->data) && $this->full) {
115 115
                 throw new Exception("{$field} field does not exist in the table {$this->table}.");
116 116
             }
117 117
 
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 
125 125
     public function where(array $where): Datamanager
126 126
     {
127
-        $this->where['AND'] = (array_key_exists('AND',$this->where)) ?? '';
127
+        $this->where['AND'] = (array_key_exists('AND', $this->where)) ?? '';
128 128
         $w = [];
129 129
         foreach ($where as $condition => $values) {
130 130
 
131
-            if(!is_array($values)){
131
+            if (!is_array($values)) {
132 132
                 $w['AND'][] = $values;
133 133
                 continue;
134 134
             }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                        
140 140
         }
141 141
 
142
-        $this->where = array_merge($this->where,$w);
142
+        $this->where = array_merge($this->where, $w);
143 143
 
144 144
         return $this;
145 145
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 
153 153
     public function offset(int $offset): Datamanager
154 154
     {
155
-        if(is_null($this->limit)){
155
+        if (is_null($this->limit)) {
156 156
             throw new Exception("The limit must be set before the offset.");
157 157
         }
158 158
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
         foreach ($arrayValues as $key => $value) {
184 184
 
185
-            if(!array_key_exists($key,$this->data)){
185
+            if (!array_key_exists($key, $this->data)) {
186 186
                 throw new Exception("{$key} field does not exist in the table {$this->table}.");
187 187
             }
188 188
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         $string = '';
197 197
         foreach ($this->data as $key => $value) {
198 198
 
199
-            if(gettype($value)==='object'){
199
+            if (gettype($value) === 'object') {
200 200
                 $value = $value->getData()[$this->primary]['value'];
201 201
             }
202 202
 
@@ -207,19 +207,19 @@  discard block
 block discarded – undo
207 207
 
208 208
     public function remove(?bool $exec = false): Datamanager
209 209
     {
210
-        if(!$exec){
210
+        if (!$exec) {
211 211
             $this->clause = 'remove';    
212 212
             return $this;
213 213
         }
214 214
 
215 215
         $this->clause = null;
216 216
 
217
-        if(count($this->where) == 1){
217
+        if (count($this->where) == 1) {
218 218
             $this->removeById();
219 219
             return $this;
220 220
         }
221 221
 
222
-        $this->delete($this->mountRemove()['where'], substr( $this->mountRemove()['data'] ,0,-1) );
222
+        $this->delete($this->mountRemove()['where'], substr($this->mountRemove()['data'], 0, -1));
223 223
 
224 224
         $this->check_fail();
225 225
             
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 
229 229
     private function removeById(): bool
230 230
     {
231
-        $delete = $this->delete("{$this->primary}=:{$this->primary}","{$this->primary}={$this->getData()[$this->primary]['value']}");
231
+        $delete = $this->delete("{$this->primary}=:{$this->primary}", "{$this->primary}={$this->getData()[$this->primary]['value']}");
232 232
 
233 233
         $this->check_fail();
234 234
 
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
         $data = [];
243 243
 
244 244
         foreach ($this->data as $key => $value) {
245
-            if(strstr($this->data[$key]['extra'],'auto_increment')){
245
+            if (strstr($this->data[$key]['extra'], 'auto_increment')) {
246 246
                 continue;
247 247
             }
248 248
 
249
-            if(strlen($value['value']) > $value['maxlength']){
249
+            if (strlen($value['value']) > $value['maxlength']) {
250 250
                 throw new Exception("The information provided for column {$key} of table {$this->table} exceeded that allowed.");
251 251
             }
252 252
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         }
257 257
 
258 258
         $this->transaction('begin');
259
-        try{
259
+        try {
260 260
            
261 261
             $id = $this->insert($data);
262 262
 
@@ -266,7 +266,7 @@  discard block
 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
         }
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 
277 277
     public function toEntity()
278 278
     {
279
-        if($this->getCount() === 0){
279
+        if ($this->getCount() === 0) {
280 280
             return null;
281 281
         }
282 282
 
283 283
         $entity = $this->setByDatabase($this->result[0]);
284 284
 
285
-        if(count($this->result) > 1){
285
+        if (count($this->result) > 1) {
286 286
             $entity = [];
287 287
             foreach ($this->result as $key => $value) {
288 288
                 $entity[] = $this->setByDatabase($value);
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
 
295 295
     public function findById($id): Datamanager
296 296
     {
297
-        $this->where([$this->primary,'=',$id]);
297
+        $this->where([$this->primary, '=', $id]);
298 298
         return $this;
299 299
     }
300 300
 
301 301
     public function execute(): Datamanager
302 302
     {
303
-        if(!is_null($this->clause) && $this->clause == 'remove'){
303
+        if (!is_null($this->clause) && $this->clause == 'remove') {
304 304
             return $this->remove(true);
305 305
         }
306 306
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
         
309 309
         $this->mountSelect();
310 310
         
311
-        $where = substr($this->mountWhereExec()['where'],0,-1);
311
+        $where = substr($this->mountWhereExec()['where'], 0, -1);
312 312
         $this->query .= " WHERE {$where} ";
313 313
 
314 314
         $this->query .= $this->order;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
     {
331 331
         $this->query = " SELECT * FROM {$this->table} ";
332 332
 
333
-        if(is_int($key)){
333
+        if (is_int($key)) {
334 334
             return $this->findById($key);
335 335
         }
336 336
 
Please login to merge, or discard this patch.
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.