Passed
Push — main ( 911b53...fad913 )
by Pranjal
02:49
created
src/Model.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      * @param string $name
46 46
      * @param Connection $connection
47 47
      */
48
-    public function __construct(string $name,Connection $connection)
48
+    public function __construct(string $name, Connection $connection)
49 49
     {
50 50
 
51 51
         $this->table = $name;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
             ($val) ? $val = 1 : $val = 0;
118 118
         }
119 119
         
120
-        if($type == 'array' || $type == 'object'){
120
+        if ($type == 'array' || $type == 'object') {
121 121
             $val = Type::getType('json_document')->convertToDatabaseValue($val, $this->connection->getDatabasePlatform());
122 122
             $type = 'json_document';
123 123
         }
124 124
 
125
-        if($type == 'string'){
125
+        if ($type == 'string') {
126 126
             $type = 'text';
127 127
         }
128 128
 
@@ -166,20 +166,20 @@  discard block
 block discarded – undo
166 166
             $parts = \Safe\preg_split('/(?=[A-Z])/', $key, -1, PREG_SPLIT_NO_EMPTY);
167 167
             if (strtolower($parts[0]) == 'own') {
168 168
                 if (strtolower($parts[2]) == 'list') {
169
-                    return $this->connection->getRecordManager()->find(strtolower($parts[1]))->where($this->getName() . '_id = "' . $this->__meta['id'] . '"')->get();
169
+                    return $this->connection->getRecordManager()->find(strtolower($parts[1]))->where($this->getName().'_id = "'.$this->__meta['id'].'"')->get();
170 170
                 }
171 171
             }
172 172
             if (strtolower($parts[0]) == 'shared') {
173 173
                 if (strtolower($parts[2]) == 'list') {
174
-                    $rel_table = $this->connection->getTableManager()->tableExists($this->table . '_' . strtolower($parts[1])) ? $this->table . '_' . strtolower($parts[1]) : strtolower($parts[1]) . '_' . $this->table;
175
-                    $relations = $this->connection->getRecordManager()->find($rel_table)->where($this->getName() . '_id = "' . $this->__meta['id'] . '"')->get();
174
+                    $rel_table = $this->connection->getTableManager()->tableExists($this->table.'_'.strtolower($parts[1])) ? $this->table.'_'.strtolower($parts[1]) : strtolower($parts[1]).'_'.$this->table;
175
+                    $relations = $this->connection->getRecordManager()->find($rel_table)->where($this->getName().'_id = "'.$this->__meta['id'].'"')->get();
176 176
                     $rel_ids = '';
177 177
                     foreach ($relations as $relation) {
178
-                        $key = strtolower($parts[1]) . '_id';
179
-                        $rel_ids .= "'" . $relation->$key . "',";
178
+                        $key = strtolower($parts[1]).'_id';
179
+                        $rel_ids .= "'".$relation->$key."',";
180 180
                     }
181 181
                     $rel_ids = substr($rel_ids, 0, -1);
182
-                    return $this->connection->getRecordManager()->find(strtolower($parts[1]))->where('id IN (' . $rel_ids . ')')->get();
182
+                    return $this->connection->getRecordManager()->find(strtolower($parts[1]))->where('id IN ('.$rel_ids.')')->get();
183 183
                 }
184 184
             }
185 185
         }
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
             return $type->convertToPHPValue($this->__properties[$key], $this->connection->getDatabasePlatform());
190 190
         }
191 191
 
192
-        if (array_key_exists($key . '_id', $this->__properties)) {
193
-            return $this->connection->getRecordManager()->getById($key, $this->__properties[$key . '_id']);
192
+        if (array_key_exists($key.'_id', $this->__properties)) {
193
+            return $this->connection->getRecordManager()->getById($key, $this->__properties[$key.'_id']);
194 194
         }
195 195
 
196 196
         throw new Exception\KeyNotFoundException();
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
      */
354 354
     public function save(): mixed
355 355
     {
356
-        if($this->__meta['id_error']){
356
+        if ($this->__meta['id_error']) {
357 357
             throw new Exception\InvalidIdException();
358 358
         }
359 359
         Event::dispatch('__arca.model.save.'.$this->connection->getConnectionId(), [$this]);
Please login to merge, or discard this patch.