Passed
Push — master ( 511eb5...e7d893 )
by Henri
03:04 queued 01:47
created
src/Datamanager.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@  discard block
 block discarded – undo
11 11
     protected ?string $table = null;
12 12
     protected ?string $primary = null;
13 13
     protected array $data = [];
14
-    protected array $where = [''=> ["1",'=',"1"] ];
14
+    protected array $where = [''=> ["1", '=', "1"]];
15 15
 
16
-    public function __set(string $prop,$value)
16
+    public function __set(string $prop, $value)
17 17
     {
18
-        if(is_array($value)){
18
+        if (is_array($value)) {
19 19
             $attr = array_keys($value)[0];
20 20
             $this->data[$prop][$attr] = $value[$attr];
21 21
             return $this;
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $deniable = (is_array($deniable)) ? $deniable : [$deniable];
51 51
 
52 52
         foreach ($deniable as $field) {
53
-            if(!array_key_exists($field,$this->data)){
53
+            if (!array_key_exists($field, $this->data)) {
54 54
                 throw new Exception("{$field} field does not exist in the table {$this->table}.");
55 55
             }
56 56
 
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 
71 71
     public function orderBy(string $field, string $ord = 'ASC')
72 72
     {
73
-        $this->isSettable( str_replace(['asc','ASC','desc','DESC',' '],'',$field) );
73
+        $this->isSettable(str_replace(['asc', 'ASC', 'desc', 'DESC', ' '], '', $field));
74 74
 
75
-        $ord = (strpos(strtolower($field),'asc') || strpos(strtolower($field),'desc')) ? '' : $ord;
75
+        $ord = (strpos(strtolower($field), 'asc') || strpos(strtolower($field), 'desc')) ? '' : $ord;
76 76
 
77 77
         $this->order = " ORDER BY {$field} {$ord} ";
78 78
         return $this;
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 
97 97
     public function where(array $where)
98 98
     {
99
-        $this->where['AND'] = (array_key_exists('AND',$this->where)) ?? '';
99
+        $this->where['AND'] = (array_key_exists('AND', $this->where)) ?? '';
100 100
         $w = [];
101 101
         foreach ($where as $condition => $values) {
102 102
 
103
-            if(!is_array($values)){
103
+            if (!is_array($values)) {
104 104
                 $w['AND'][] = $values;
105 105
                 continue;
106 106
             }
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                        
112 112
         }
113 113
 
114
-        $this->where = array_merge($this->where,$w);
114
+        $this->where = array_merge($this->where, $w);
115 115
 
116 116
         return $this;
117 117
     }
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         $string = '';
166 166
         foreach ($this->data as $key => $value) {
167 167
 
168
-            if(gettype($value)==='object'){
168
+            if (gettype($value) === 'object') {
169 169
                 $value = $value->getData()[$this->primary]['value'];
170 170
             }
171 171
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
     private function removeById(): bool
178 178
     {
179
-        $delete = $this->delete("{$this->primary}=:{$this->primary}","{$this->primary}={$this->getData()[$this->primary]['value']}");
179
+        $delete = $this->delete("{$this->primary}=:{$this->primary}", "{$this->primary}={$this->getData()[$this->primary]['value']}");
180 180
 
181 181
         $this->check_fail();
182 182
 
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 
186 186
     public function findById($id)
187 187
     {
188
-        return $this->where([$this->primary,'=',$id]);
188
+        return $this->where([$this->primary, '=', $id]);
189 189
     }
190 190
 
191 191
     public function execute()
192 192
     {
193
-        if(!is_null($this->clause) && $this->clause == 'remove'){
193
+        if (!is_null($this->clause) && $this->clause == 'remove') {
194 194
             return $this->remove(true);
195 195
         }
196 196
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         
199 199
         $this->mountSelect();
200 200
         
201
-        $where = substr($this->mountWhereExec()['where'],0,-1);
201
+        $where = substr($this->mountWhereExec()['where'], 0, -1);
202 202
         $this->query .= " WHERE {$where} ";
203 203
 
204 204
         $this->query .= $this->order;
Please login to merge, or discard this patch.
src/EntityTrait.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
4 4
 
5 5
 use Exception;
6 6
 
7
-trait EntityTrait{
7
+trait EntityTrait {
8 8
     public function toEntity()
9 9
     {
10
-        if($this->getCount() === 0){
10
+        if ($this->getCount() === 0) {
11 11
             return null;
12 12
         }
13 13
 
14 14
         $entity = $this->setByDatabase($this->result[0]);
15 15
 
16
-        if(count($this->result) > 1){
16
+        if (count($this->result) > 1) {
17 17
             $entity = [];
18 18
             foreach ($this->result as $key => $value) {
19 19
                 $entity[] = $this->setByDatabase($value);
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         $data = [];
31 31
 
32 32
         foreach ($this->data as $key => $value) {
33
-            if(strstr($this->data[$key]['extra'],'auto_increment')){
33
+            if (strstr($this->data[$key]['extra'], 'auto_increment')) {
34 34
                 continue;
35 35
             }
36 36
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         }
43 43
 
44 44
         $this->transaction('begin');
45
-        try{
45
+        try {
46 46
            
47 47
             $id = $this->insert($data);
48 48
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             
53 53
             $this->transaction('commit');
54 54
 
55
-        }catch(Exception $er){
55
+        } catch (Exception $er) {
56 56
             $this->transaction('rollback');
57 57
             throw $er;
58 58
         }
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 
63 63
     public function remove(?bool $exec = false)
64 64
     {
65
-        if($exec !== null){
65
+        if ($exec !== null) {
66 66
             $this->clause = 'remove';    
67 67
             return $this;
68 68
         }
69 69
 
70 70
         $this->clause = null;
71 71
 
72
-        if(count($this->where) == 1){
72
+        if (count($this->where) == 1) {
73 73
             $this->removeById();
74 74
             return $this;
75 75
         }
76 76
 
77
-        $this->delete($this->mountRemove()['where'], substr( $this->mountRemove()['data'] ,0,-1) );
77
+        $this->delete($this->mountRemove()['where'], substr($this->mountRemove()['data'], 0, -1));
78 78
 
79 79
         $this->check_fail();
80 80
             
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $this->transaction('begin');
87 87
 
88
-        try{
88
+        try {
89 89
             $this->update(
90 90
                 $this->mountSave()['data'],
91 91
                 "{$this->primary}=:{$this->primary}", 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
             $this->check_fail();
96 96
 
97 97
             $this->transaction('commit');
98
-        }catch(Exception $er){
98
+        } catch (Exception $er) {
99 99
             $this->transaction('rollback');
100 100
             throw $er;
101 101
         }
Please login to merge, or discard this patch.