Passed
Push — main ( f9384e...7dc7cf )
by Pranjal
02:26
created
src/Model.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
             }
114 114
         }
115 115
         if ($val instanceof Model) {
116
-            if (isset($this->__props[$key . '_id'])) {
117
-                unset($this->__props[$key . '_id']);
116
+            if (isset($this->__props[$key.'_id'])) {
117
+                unset($this->__props[$key.'_id']);
118 118
             }
119 119
             $this->__meta['has_foreign']['oto'] = true;
120 120
             array_push($this->__meta['foreign_models']['oto'], $val);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      * @throws \Scrawler\Arca\Exception\InvalidModelException
150 150
      * @return Collection
151 151
      */
152
-    private function arrayToCollection(array|Collection $models): Collection
152
+    private function arrayToCollection(array | Collection $models): Collection
153 153
     {
154 154
         if ($models instanceof Collection) {
155 155
             return $models;
@@ -187,30 +187,30 @@  discard block
 block discarded – undo
187 187
             $parts = \Safe\preg_split('/(?=[A-Z])/', $key, -1, PREG_SPLIT_NO_EMPTY);
188 188
             if (strtolower($parts[0]) == 'own') {
189 189
                 if (strtolower($parts[2]) == 'list') {
190
-                    $result = $this->connection->getRecordManager()->find(strtolower($parts[1]))->where($this->getName() . '_id = "' . $this->__meta['id'] . '"')->get();
190
+                    $result = $this->connection->getRecordManager()->find(strtolower($parts[1]))->where($this->getName().'_id = "'.$this->__meta['id'].'"')->get();
191 191
                     $this->set($key, $result);
192 192
                     return $result;
193 193
                 }
194 194
             }
195 195
             if (strtolower($parts[0]) == 'shared') {
196 196
                 if (strtolower($parts[2]) == 'list') {
197
-                    $rel_table = $this->connection->getTableManager()->tableExists($this->table . '_' . strtolower($parts[1])) ? $this->table . '_' . strtolower($parts[1]) : strtolower($parts[1]) . '_' . $this->table;
198
-                    $relations = $this->connection->getRecordManager()->find($rel_table)->where($this->getName() . '_id = "' . $this->__meta['id'] . '"')->get();
197
+                    $rel_table = $this->connection->getTableManager()->tableExists($this->table.'_'.strtolower($parts[1])) ? $this->table.'_'.strtolower($parts[1]) : strtolower($parts[1]).'_'.$this->table;
198
+                    $relations = $this->connection->getRecordManager()->find($rel_table)->where($this->getName().'_id = "'.$this->__meta['id'].'"')->get();
199 199
                     $rel_ids = '';
200 200
                     foreach ($relations as $relation) {
201
-                        $key = strtolower($parts[1]) . '_id';
202
-                        $rel_ids .= "'" . $relation->$key . "',";
201
+                        $key = strtolower($parts[1]).'_id';
202
+                        $rel_ids .= "'".$relation->$key."',";
203 203
                     }
204 204
                     $rel_ids = substr($rel_ids, 0, -1);
205
-                    $result = $this->connection->getRecordManager()->find(strtolower($parts[1]))->where('id IN (' . $rel_ids . ')')->get();
205
+                    $result = $this->connection->getRecordManager()->find(strtolower($parts[1]))->where('id IN ('.$rel_ids.')')->get();
206 206
                     $this->set($key, $result);
207 207
                     return $result;
208 208
                 }
209 209
             }
210 210
         }
211 211
 
212
-        if (array_key_exists($key . '_id', $this->__properties)) {
213
-            $result = $this->connection->getRecordManager()->getById($key, $this->__properties[$key . '_id']);
212
+        if (array_key_exists($key.'_id', $this->__properties)) {
213
+            $result = $this->connection->getRecordManager()->getById($key, $this->__properties[$key.'_id']);
214 214
             $this->set($key, $result);
215 215
             return $result;
216 216
         }
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
      */
412 412
     public function save(): mixed
413 413
     {
414
-        Event::dispatch('__arca.model.save.' . $this->connection->getConnectionId(), [$this]);
414
+        Event::dispatch('__arca.model.save.'.$this->connection->getConnectionId(), [$this]);
415 415
 
416 416
         return $this->getId();
417 417
     }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
      */
440 440
     public function delete(): void
441 441
     {
442
-        Event::dispatch('__arca.model.delete.' . $this->connection->getConnectionId(), [$this]);
442
+        Event::dispatch('__arca.model.delete.'.$this->connection->getConnectionId(), [$this]);
443 443
     }
444 444
 
445 445
     /**
Please login to merge, or discard this patch.