Passed
Branch main (08d999)
by Sammy
03:02
created
Controllers/ORMController.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
     public function formModel(ModelInterface $setter = null): ModelInterface
34 34
     {
35
-      if(!is_null($setter)){
35
+      if (!is_null($setter)) {
36 36
         $this->form_model = $setter;
37 37
       }
38
-      elseif(is_null($this->form_model)){
38
+      elseif (is_null($this->form_model)) {
39 39
         $reflection = new \ReflectionClass($this->modelClassName());
40 40
         $this->form_model = $reflection->newInstanceWithoutConstructor(); //That's it!
41 41
       }
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
     public function modelType(): string
47 47
     {
48 48
       // have to go through the model to garantee model_type existence via interface
49
-      if(is_null($this->model_type))
49
+      if (is_null($this->model_type))
50 50
         $this->model_type = get_class($this->formModel())::model_type();
51 51
 
52 52
       return $this->model_type;
53 53
     }
54 54
 
55
-    public function modelPrefix($suffix=null): string
55
+    public function modelPrefix($suffix = null): string
56 56
     {
57 57
       $ret = $this->modelType();
58 58
 
59
-      if(!is_null($suffix))
59
+      if (!is_null($suffix))
60 60
         $ret .= '_'.$suffix;
61 61
 
62 62
       return $ret;
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
         $this->viewport('listing_fields', $listing_fields);
175 175
         $this->viewport('listing_template', $listing_template);
176 176
 
177
-        $this->viewport('route_new', $this->router()->prehop($class_name::model_type() . '_new'));
178
-        $this->viewport('route_export', $this->router()->prehop($class_name::model_type() . '_export'));
177
+        $this->viewport('route_new', $this->router()->prehop($class_name::model_type().'_new'));
178
+        $this->viewport('route_export', $this->router()->prehop($class_name::model_type().'_export'));
179 179
     }
180 180
 
181 181
     public function copy()
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
     {
207 207
         $this->errors = $model->save($this->operator()->operator_id()); // returns [errors]
208 208
         if (empty($this->errors())) {
209
-            $this->logger()->nice($this->l('CRUDITES_INSTANCE_ALTERED', [$this->l('MODEL_' . get_class($model)::model_type() . '_INSTANCE')]));
209
+            $this->logger()->nice($this->l('CRUDITES_INSTANCE_ALTERED', [$this->l('MODEL_'.get_class($model)::model_type().'_INSTANCE')]));
210 210
             return $model;
211 211
         }
212 212
         foreach ($this->errors() as $field => $error_msg) {
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     public function before_edit()
220 220
     {
221 221
         if (!is_null($this->router()->params('id')) && is_null($this->load_model)) {
222
-            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_' . $this->modelClassName()::model_type() . '_INSTANCE')]));
222
+            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_'.$this->modelClassName()::model_type().'_INSTANCE')]));
223 223
             $this->router()->hop($this->modelClassName()::model_type());
224 224
         }
225 225
     }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     public function destroy_confirm()
239 239
     {
240 240
         if (is_null($this->load_model)) {
241
-            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')]));
241
+            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')]));
242 242
             $this->router()->hop($this->model_type);
243 243
         }
244 244
 
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
     public function before_destroy() // default: checks for load_model and immortality, hops back to object on failure
251 251
     {
252 252
         if (is_null($this->load_model)) {
253
-            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')]));
253
+            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')]));
254 254
             $this->router()->hop($this->model_type);
255 255
         } elseif ($this->load_model->immortal()) {
256
-            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')]));
256
+            $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')]));
257 257
             $this->router()->hop($this->route_model($this->load_model));
258 258
         }
259 259
     }
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
         }
266 266
 
267 267
         if ($this->load_model->destroy($this->operator()->operator_id()) === false) {
268
-            $this->logger()->info($this->l('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', ['' . $this->load_model]));
268
+            $this->logger()->info($this->l('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model]));
269 269
             $this->route_back($this->load_model);
270 270
         } else {
271
-            $this->logger()->nice($this->l('CRUDITES_INSTANCE_DESTROYED', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')]));
271
+            $this->logger()->nice($this->l('CRUDITES_INSTANCE_DESTROYED', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')]));
272 272
             $this->route_back($this->model_type);
273 273
         }
274 274
     }
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
     public function collection_to_csv($collection, $filename)
295 295
     {
296 296
       // TODO use Format/File/CSV class to generate file
297
-        $file_path = $this->box('settings.export.directory') . $filename . '.csv';
297
+        $file_path = $this->box('settings.export.directory').$filename.'.csv';
298 298
         $fp = fopen($file_path, 'w');
299 299
 
300 300
         $header = false;
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
     public function route_new(ModelInterface $model): string
333 333
     {
334
-        return $this->router()->prehop(get_class($model)::model_type() . '_new');
334
+        return $this->router()->prehop(get_class($model)::model_type().'_new');
335 335
     }
336 336
 
337 337
     public function route_list(ModelInterface $model): string
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
     {
344 344
         $route_params = [];
345 345
 
346
-        $route_name = get_class($model)::model_type() . '_';
346
+        $route_name = get_class($model)::model_type().'_';
347 347
         if ($model->is_new()) {
348 348
             $route_name .= 'new';
349 349
         } else {
Please login to merge, or discard this patch.
Braces   +7 added lines, -6 removed lines patch added patch discarded remove patch
@@ -34,8 +34,7 @@  discard block
 block discarded – undo
34 34
     {
35 35
       if(!is_null($setter)){
36 36
         $this->form_model = $setter;
37
-      }
38
-      elseif(is_null($this->form_model)){
37
+      } elseif(is_null($this->form_model)){
39 38
         $reflection = new \ReflectionClass($this->modelClassName());
40 39
         $this->form_model = $reflection->newInstanceWithoutConstructor(); //That's it!
41 40
       }
@@ -46,8 +45,9 @@  discard block
 block discarded – undo
46 45
     public function modelType(): string
47 46
     {
48 47
       // have to go through the model to garantee model_type existence via interface
49
-      if(is_null($this->model_type))
50
-        $this->model_type = get_class($this->formModel())::model_type();
48
+      if(is_null($this->model_type)) {
49
+              $this->model_type = get_class($this->formModel())::model_type();
50
+      }
51 51
 
52 52
       return $this->model_type;
53 53
     }
@@ -56,8 +56,9 @@  discard block
 block discarded – undo
56 56
     {
57 57
       $ret = $this->modelType();
58 58
 
59
-      if(!is_null($suffix))
60
-        $ret .= '_'.$suffix;
59
+      if(!is_null($suffix)) {
60
+              $ret .= '_'.$suffix;
61
+      }
61 62
 
62 63
       return $ret;
63 64
     }
Please login to merge, or discard this patch.