Passed
Push — master ( 4c3e72...46eb59 )
by Arthur
10:39
created
src/Foundation/Tests/TransformerTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $this->machineNoUser = new MachineTestModel(null);
29 29
     }
30 30
 
31
-    public function testNoRelation(){
31
+    public function testNoRelation() {
32 32
         $machineResource = MachineTestTransformer::resource($this->machine)->serialize();
33 33
         $this->assertEmpty($machineResource);
34 34
         $this->assertArrayNotHasKey('user', $machineResource);
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
         $this->assertArrayHasKey('user', $machineResource);
41 41
     }
42 42
 
43
-    public function testEmptyRelation(){
43
+    public function testEmptyRelation() {
44 44
         $machineResource = MachineTestTransformer::resource($this->machineNoUser)->include('user')->serialize();
45 45
         $this->assertArrayHasKey('user', $machineResource);
46
-        $this->assertNull($machineResource['user']);
46
+        $this->assertNull($machineResource[ 'user' ]);
47 47
     }
48 48
 
49
-    public function testPreIncludedRelation(){
49
+    public function testPreIncludedRelation() {
50 50
         $machineResource = UserIncludedMachineTestTransformer::resource($this->machine)->serialize();
51 51
         $this->assertArrayHasKey('user', $machineResource);
52 52
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 class MachineTestTransformer extends Transformer {
70 70
     public function toArray($request)
71 71
     {
72
-        return [];
72
+        return [ ];
73 73
     }
74 74
 
75 75
     public function transformUser(MachineTestModel $machine)
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 }
80 80
 
81 81
 class UserIncludedMachineTestTransformer extends MachineTestTransformer {
82
-    protected $include = ['user'];
82
+    protected $include = [ 'user' ];
83 83
 }
84 84
 
85 85
 class UserTestTransformer extends Transformer {
86 86
 
87 87
     public function toArray($request)
88 88
     {
89
-        return [];
89
+        return [ ];
90 90
     }
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
src/Foundation/Cache/ModelCache.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     /**
25 25
      * ModelCache constructor.
26 26
      */
27
-    public function __construct(string $model, array $indexes = [], $cacheTime = null)
27
+    public function __construct(string $model, array $indexes = [ ], $cacheTime = null)
28 28
     {
29 29
         $this->model = $model;
30 30
         $this->secondaryIndexes = $indexes;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     protected function eagerLoadRelations($model)
69 69
     {
70 70
         if ($model !== null) {
71
-            return $model::eagerLoadRelations([$model])[0];
71
+            return $model::eagerLoadRelations([ $model ])[ 0 ];
72 72
         }
73 73
     }
74 74
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function getCacheName($id, string $index = 'id')
84 84
     {
85
-        return config('model.cache_prefix') . ':' . strtolower(get_short_class_name($this->model)) . ':' . $index . ':' . $id;
85
+        return config('model.cache_prefix').':'.strtolower(get_short_class_name($this->model)).':'.$index.':'.$id;
86 86
     }
87 87
 
88 88
     /**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     private static function deleteWithPrefix($prefix)
142 142
     {
143 143
         $redis = self::getCacheConnection();
144
-        $keyPattern = Cache::getPrefix() . $prefix . '*';
144
+        $keyPattern = Cache::getPrefix().$prefix.'*';
145 145
         $keys = $redis->keys($keyPattern);
146 146
         $redis->delete($keys);
147 147
     }
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
      */
168 168
     public function clearModelCache()
169 169
     {
170
-        $pattern = config('model.cache_prefix') . ':' . strtolower(get_short_class_name($this->model));
170
+        $pattern = config('model.cache_prefix').':'.strtolower(get_short_class_name($this->model));
171 171
         self::deleteWithPrefix($pattern);
172 172
     }
173 173
 
174 174
     public function enabled(): bool
175 175
     {
176
-        return (bool)config('model.caching');
176
+        return (bool) config('model.caching');
177 177
     }
178 178
 }
Please login to merge, or discard this patch.
src/Foundation/Console/SeedCommand.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
         $this->resolver->setDefaultConnection($this->getDatabase());
36 36
 
37
-        Model::unguarded(function () {
37
+        Model::unguarded(function() {
38 38
             foreach ($this->getSeeders() as $seeder) {
39 39
                 $seeder = $this->laravel->make($seeder);
40 40
                 if (!isset($seeder->enabled) || $seeder->enabled)
@@ -49,6 +49,6 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $this->service = $this->laravel->make(BootstrapRegistrarService::class);
51 51
 
52
-        return $this->service->getSeeders() ?? [];
52
+        return $this->service->getSeeders() ?? [ ];
53 53
     }
54 54
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -37,8 +37,9 @@
 block discarded – undo
37 37
         Model::unguarded(function () {
38 38
             foreach ($this->getSeeders() as $seeder) {
39 39
                 $seeder = $this->laravel->make($seeder);
40
-                if (!isset($seeder->enabled) || $seeder->enabled)
41
-                    $seeder->__invoke();
40
+                if (!isset($seeder->enabled) || $seeder->enabled) {
41
+                                    $seeder->__invoke();
42
+                }
42 43
             }
43 44
         });
44 45
 
Please login to merge, or discard this patch.
src/Foundation/Services/BootstrapRegistrarService.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
      */
89 89
     private function buildEmptyBootstrapArray()
90 90
     {
91
-        $bootstrapArray = [];
91
+        $bootstrapArray = [ ];
92 92
         foreach ($this->moduleEntityDirectories as $key => $directory) {
93
-            $bootstrapArray[$key] = [];
93
+            $bootstrapArray[ $key ] = [ ];
94 94
         }
95 95
 
96 96
         return $bootstrapArray;
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
     private function getModules(): array
103 103
     {
104 104
         $path = base_path('src/Modules');
105
-        $moduleNames = array_diff(scandir($path), ['..', '.']);
106
-        $modules = [];
105
+        $moduleNames = array_diff(scandir($path), [ '..', '.' ]);
106
+        $modules = [ ];
107 107
         foreach ($moduleNames as $moduleName) {
108
-            $modules[$moduleName] = $path.'/'.$moduleName;
108
+            $modules[ $moduleName ] = $path.'/'.$moduleName;
109 109
         }
110 110
 
111 111
         return $modules;
@@ -135,38 +135,38 @@  discard block
 block discarded – undo
135 135
                                         try {
136 136
                                             $command = new $class();
137 137
                                             if ($command instanceof Command) {
138
-                                                $bootstrap[$key][] = $class;
138
+                                                $bootstrap[ $key ][ ] = $class;
139 139
                                             }
140 140
                                         } catch (\Exception $e) {
141 141
                                             break;
142 142
                                         }
143 143
                                         break;
144 144
                                     case 'routes':
145
-                                        $bootstrap[$key][] = $this->buildRouteArray($directoryPath.'/'.$fileName, $namespace);
145
+                                        $bootstrap[ $key ][ ] = $this->buildRouteArray($directoryPath.'/'.$fileName, $namespace);
146 146
                                         break;
147 147
                                     case 'configs':
148
-                                        $bootstrap[$key][] = $this->buildConfigArray($directoryPath.'/'.$fileName, $moduleName, $fileName);
148
+                                        $bootstrap[ $key ][ ] = $this->buildConfigArray($directoryPath.'/'.$fileName, $moduleName, $fileName);
149 149
                                         break;
150 150
                                     case 'factories':
151
-                                        $bootstrap[$key][] = $this->buildDirectoryPathArray($directoryPath);
151
+                                        $bootstrap[ $key ][ ] = $this->buildDirectoryPathArray($directoryPath);
152 152
                                         break;
153 153
                                     case 'migrations':
154
-                                        $bootstrap[$key][] = $this->buildDirectoryPathArray($directoryPath);
154
+                                        $bootstrap[ $key ][ ] = $this->buildDirectoryPathArray($directoryPath);
155 155
                                         break;
156 156
                                     case 'seeders':
157
-                                        $bootstrap[$key][] = $class;
157
+                                        $bootstrap[ $key ][ ] = $class;
158 158
                                         break;
159 159
                                     case 'models':
160
-                                        $bootstrap[$key][] = $class;
160
+                                        $bootstrap[ $key ][ ] = $class;
161 161
                                         break;
162 162
                                     case 'policies':
163
-                                        $bootstrap[$key][] = $this->buildPolicyArray($class, $namespace);
163
+                                        $bootstrap[ $key ][ ] = $this->buildPolicyArray($class, $namespace);
164 164
                                         break;
165 165
                                     case 'providers':
166
-                                        $bootstrap[$key][] = $class;
166
+                                        $bootstrap[ $key ][ ] = $class;
167 167
                                         break;
168 168
                                     case 'events':
169
-                                        $bootstrap[$key][] = $this->buildEventsArray($class);
169
+                                        $bootstrap[ $key ][ ] = $this->buildEventsArray($class);
170 170
                                         break;
171 171
                                     default:
172 172
                                         break;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      */
189 189
     private function hasPhpExtension(string $fileName): bool
190 190
     {
191
-        return strlen($fileName) > 4 && '.php' === ($fileName[-4].$fileName[-3].$fileName[-2].$fileName[-1]);
191
+        return strlen($fileName) > 4 && '.php' === ($fileName[-4 ].$fileName[-3 ].$fileName[-2 ].$fileName[-1 ]);
192 192
     }
193 193
 
194 194
     /**
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         $apiDomain = str_replace('http://', '', $apiDomain);
220 220
         $apiDomain = str_replace('https://', '', $apiDomain);
221 221
         $moduleNamespace = $namespace;
222
-        $moduleName = explode('\\', $moduleNamespace)[1];
222
+        $moduleName = explode('\\', $moduleNamespace)[ 1 ];
223 223
         $controllerNamespace = $moduleNamespace.'\\'.'Http\\Controllers';
224 224
         $modelNameSpace = $moduleNamespace.'\\'.'Entities\\'.$moduleName;
225 225
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     private function buildPolicyArray($class, $namespace)
243 243
     {
244 244
         $moduleNamespace = $namespace;
245
-        $moduleName = explode('\\', $moduleNamespace)[1];
245
+        $moduleName = explode('\\', $moduleNamespace)[ 1 ];
246 246
         $modelNameSpace = $moduleNamespace.'\\'.'Entities\\'.$moduleName;
247 247
 
248 248
         return [
@@ -280,11 +280,11 @@  discard block
 block discarded – undo
280 280
 
281 281
     private function buildEventsArray($class)
282 282
     {
283
-        $listenerProperties = get_class_property($class, 'listeners') ?? [];
284
-        $listeners = [];
283
+        $listenerProperties = get_class_property($class, 'listeners') ?? [ ];
284
+        $listeners = [ ];
285 285
         foreach ($listenerProperties as $listener) {
286 286
             if (class_implements_interface($listener, ListenerContract::class)) {
287
-                $listeners[] = $listener;
287
+                $listeners[ ] = $listener;
288 288
             }
289 289
         }
290 290
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
      */
300 300
     public function getCommands(): array
301 301
     {
302
-        return $this->loadBootstrapFromCache()['commands'] ?? [];
302
+        return $this->loadBootstrapFromCache()[ 'commands' ] ?? [ ];
303 303
     }
304 304
 
305 305
     /**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      */
308 308
     public function getRoutes(): array
309 309
     {
310
-        return $this->loadBootstrapFromCache()['routes'] ?? [];
310
+        return $this->loadBootstrapFromCache()[ 'routes' ] ?? [ ];
311 311
     }
312 312
 
313 313
     /**
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function getConfigs(): array
317 317
     {
318
-        return $this->loadBootstrapFromCache()['configs'] ?? [];
318
+        return $this->loadBootstrapFromCache()[ 'configs' ] ?? [ ];
319 319
     }
320 320
 
321 321
     /**
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
      */
324 324
     public function getFactories(): array
325 325
     {
326
-        return $this->loadBootstrapFromCache()['factories'] ?? [];
326
+        return $this->loadBootstrapFromCache()[ 'factories' ] ?? [ ];
327 327
     }
328 328
 
329 329
     /**
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public function getMigrations(): array
333 333
     {
334
-        return $this->loadBootstrapFromCache()['migrations'] ?? [];
334
+        return $this->loadBootstrapFromCache()[ 'migrations' ] ?? [ ];
335 335
     }
336 336
 
337 337
     /**
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      */
340 340
     public function getSeeders(): array
341 341
     {
342
-        return $this->loadBootstrapFromCache()['seeders'] ?? [];
342
+        return $this->loadBootstrapFromCache()[ 'seeders' ] ?? [ ];
343 343
     }
344 344
 
345 345
     /**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
      */
348 348
     public function getModels(): array
349 349
     {
350
-        return $this->loadBootstrapFromCache()['models'] ?? [];
350
+        return $this->loadBootstrapFromCache()[ 'models' ] ?? [ ];
351 351
     }
352 352
 
353 353
     /**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
      */
356 356
     public function getPolicies(): array
357 357
     {
358
-        return $this->loadBootstrapFromCache()['policies'] ?? [];
358
+        return $this->loadBootstrapFromCache()[ 'policies' ] ?? [ ];
359 359
     }
360 360
 
361 361
     /**
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
      */
364 364
     public function getProviders(): array
365 365
     {
366
-        return $this->loadBootstrapFromCache()['providers'] ?? [];
366
+        return $this->loadBootstrapFromCache()[ 'providers' ] ?? [ ];
367 367
     }
368 368
 
369 369
     /**
@@ -371,6 +371,6 @@  discard block
 block discarded – undo
371 371
      */
372 372
     public function getEvents(): array
373 373
     {
374
-        return $this->loadBootstrapFromCache()['events'] ?? [];
374
+        return $this->loadBootstrapFromCache()[ 'events' ] ?? [ ];
375 375
     }
376 376
 }
Please login to merge, or discard this patch.
src/Foundation/Abstracts/Transformers/Transformer.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 
13 13
 abstract class Transformer extends JsonResource
14 14
 {
15
-    protected $include = [];
15
+    protected $include = [ ];
16 16
 
17
-    protected $available = [];
17
+    protected $available = [ ];
18 18
 
19 19
     /**
20 20
      * Resolve the resource to an array.
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         if (isset($request->include) && is_string($request->include))
35 35
             return explode(',', $request->include);
36 36
 
37
-        return [];
37
+        return [ ];
38 38
     }
39 39
 
40 40
     protected function compileRelations(array $includedRequestRelations)
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 
45 45
     protected function includeRelations($requestedRelations)
46 46
     {
47
-        $relations = [];
47
+        $relations = [ ];
48 48
         foreach ($this->compileRelations($requestedRelations) as $relation) {
49
-            if (is_string($relation) && method_exists($this, 'transform' . ucfirst(strtolower($relation)))) {
49
+            if (is_string($relation) && method_exists($this, 'transform'.ucfirst(strtolower($relation)))) {
50 50
                 $data = null;
51 51
                 if ($this->resource !== null) {
52
-                    $method = 'transform' . ucfirst(strtolower($relation));
52
+                    $method = 'transform'.ucfirst(strtolower($relation));
53 53
                     $data = $this->$method($this->resource);
54 54
                 }
55 55
                 if ($data instanceof JsonResource) {
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
                     else
59 59
                         $data->jsonSerialize();
60 60
                 }
61
-                $relations[strtolower($relation)] = $data;
61
+                $relations[ strtolower($relation) ] = $data;
62 62
             } else {
63
-                throw new \Exception('invalid relation or not relation_transform_method given in ' . get_short_class_name(static::class));
63
+                throw new \Exception('invalid relation or not relation_transform_method given in '.get_short_class_name(static::class));
64 64
             }
65 65
         }
66 66
 
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function include($relations)
74 74
     {
75 75
         if (is_string($relations))
76
-            $relations = [$relations];
76
+            $relations = [ $relations ];
77 77
         $this->include = array_unique(array_merge($this->include, $relations));
78 78
         return $this;
79 79
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     public function available($relations)
85 85
     {
86 86
         if (is_string($relations))
87
-            $relations = [$relations];
87
+            $relations = [ $relations ];
88 88
         $this->available = array_unique(array_merge($this->available, $relations));
89 89
         return $this;
90 90
     }
Please login to merge, or discard this patch.
Braces   +14 added lines, -10 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
 
32 32
     protected function parseRequestIncludeParameter($request)
33 33
     {
34
-        if (isset($request->include) && is_string($request->include))
35
-            return explode(',', $request->include);
34
+        if (isset($request->include) && is_string($request->include)) {
35
+                    return explode(',', $request->include);
36
+        }
36 37
 
37 38
         return [];
38 39
     }
@@ -53,10 +54,11 @@  discard block
 block discarded – undo
53 54
                     $data = $this->$method($this->resource);
54 55
                 }
55 56
                 if ($data instanceof JsonResource) {
56
-                    if ($data->resource === null)
57
-                        $data = null;
58
-                    else
59
-                        $data->jsonSerialize();
57
+                    if ($data->resource === null) {
58
+                                            $data = null;
59
+                    } else {
60
+                                            $data->jsonSerialize();
61
+                    }
60 62
                 }
61 63
                 $relations[strtolower($relation)] = $data;
62 64
             } else {
@@ -72,8 +74,9 @@  discard block
 block discarded – undo
72 74
      */
73 75
     public function include($relations)
74 76
     {
75
-        if (is_string($relations))
76
-            $relations = [$relations];
77
+        if (is_string($relations)) {
78
+                    $relations = [$relations];
79
+        }
77 80
         $this->include = array_unique(array_merge($this->include, $relations));
78 81
         return $this;
79 82
     }
@@ -83,8 +86,9 @@  discard block
 block discarded – undo
83 86
      */
84 87
     public function available($relations)
85 88
     {
86
-        if (is_string($relations))
87
-            $relations = [$relations];
89
+        if (is_string($relations)) {
90
+                    $relations = [$relations];
91
+        }
88 92
         $this->available = array_unique(array_merge($this->available, $relations));
89 93
         return $this;
90 94
     }
Please login to merge, or discard this patch.