Completed
Pull Request — master (#1105)
by Dovydas
09:11
created
src/Commands/MigrateCommand.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         }
48 48
 
49 49
         foreach ($this->module->getOrdered($this->option('direction')) as $module) {
50
-            $this->line('Running for module: <info>' . $module->getName() . '</info>');
50
+            $this->line('Running for module: <info>'.$module->getName().'</info>');
51 51
 
52 52
             $this->migrate($module);
53 53
         }
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
         $path = str_replace(base_path(), '', (new Migrator($module, $this->getLaravel()))->getPath());
64 64
 
65 65
         if ($this->option('subpath')) {
66
-            $path = $path . "/" . $this->option("subpath");
66
+            $path = $path."/".$this->option("subpath");
67 67
         }
68 68
 
69 69
         $this->call('migrate', [
Please login to merge, or discard this patch.
src/FileRepository.php 2 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,9 +126,7 @@  discard block
 block discarded – undo
126 126
     /**
127 127
      * Creates a new Module instance
128 128
      *
129
-     * @param Container $app
130
-     * @param string $args
131
-     * @param string $path
129
+     * @param string[] $args
132 130
      * @return \Nwidart\Modules\Module
133 131
      */
134 132
     abstract protected function createModule(...$args);
@@ -632,7 +630,7 @@  discard block
 block discarded – undo
632 630
     /**
633 631
      * Get stub path.
634 632
      *
635
-     * @return string|null
633
+     * @return string|boolean
636 634
      */
637 635
     public function getStubPath()
638 636
     {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             $paths = array_merge($paths, $this->config('scan.paths'));
117 117
         }
118 118
 
119
-        $paths = array_map(function ($path) {
119
+        $paths = array_map(function($path) {
120 120
             return Str::endsWith($path, '/*') ? $path : Str::finish($path, '/*');
121 121
         }, $paths);
122 122
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function getCached()
202 202
     {
203
-        return $this->cache->remember($this->config('cache.key'), $this->config('cache.lifetime'), function () {
203
+        return $this->cache->remember($this->config('cache.key'), $this->config('cache.lifetime'), function() {
204 204
             return $this->toCollection()->toArray();
205 205
         });
206 206
     }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
     {
290 290
         $modules = $this->allEnabled();
291 291
 
292
-        uasort($modules, function (Module $a, Module $b) use ($direction) {
292
+        uasort($modules, function(Module $a, Module $b) use ($direction) {
293 293
             if ($a->get('priority') === $b->get('priority')) {
294 294
                 return 0;
295 295
             }
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
     public function getModulePath($module)
419 419
     {
420 420
         try {
421
-            return $this->findOrFail($module)->getPath() . '/';
421
+            return $this->findOrFail($module)->getPath().'/';
422 422
         } catch (ModuleNotFoundException $e) {
423
-            return $this->getPath() . '/' . Str::studly($module) . '/';
423
+            return $this->getPath().'/'.Str::studly($module).'/';
424 424
         }
425 425
     }
426 426
 
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
      */
430 430
     public function assetPath(string $module) : string
431 431
     {
432
-        return $this->config('paths.assets') . '/' . $module;
432
+        return $this->config('paths.assets').'/'.$module;
433 433
     }
434 434
 
435 435
     /**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      */
438 438
     public function config(string $key, $default = null)
439 439
     {
440
-        return $this->config->get('modules.' . $key, $default);
440
+        return $this->config->get('modules.'.$key, $default);
441 441
     }
442 442
 
443 443
     /**
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
         }
528 528
         list($name, $url) = explode(':', $asset);
529 529
 
530
-        $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
530
+        $baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
531 531
 
532
-        $url = $this->url->asset($baseUrl . "/{$name}/" . $url);
532
+        $url = $this->url->asset($baseUrl."/{$name}/".$url);
533 533
 
534 534
         return str_replace(['http://', 'https://'], '//', $url);
535 535
     }
Please login to merge, or discard this patch.
src/Module.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
     /**
240 240
      * Get a specific data from composer.json file by given the key.
241 241
      *
242
-     * @param $key
242
+     * @param string $key
243 243
      * @param null $default
244 244
      *
245 245
      * @return mixed
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     {
204 204
         $lowerName = $this->getLowerName();
205 205
 
206
-        $langPath = $this->getPath() . '/Resources/lang';
206
+        $langPath = $this->getPath().'/Resources/lang';
207 207
 
208 208
         if (is_dir($langPath)) {
209 209
             $this->loadTranslationsFrom($langPath, $lowerName);
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
             $file = 'module.json';
224 224
         }
225 225
 
226
-        return Arr::get($this->moduleJson, $file, function () use ($file) {
227
-            return $this->moduleJson[$file] = new Json($this->getPath() . '/' . $file, $this->files);
226
+        return Arr::get($this->moduleJson, $file, function() use ($file) {
227
+            return $this->moduleJson[$file] = new Json($this->getPath().'/'.$file, $this->files);
228 228
         });
229 229
     }
230 230
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
      */
278 278
     protected function fireEvent($event): void
279 279
     {
280
-        $this->app['events']->dispatch(sprintf('modules.%s.' . $event, $this->getLowerName()), [$this]);
280
+        $this->app['events']->dispatch(sprintf('modules.%s.'.$event, $this->getLowerName()), [$this]);
281 281
     }
282 282
     /**
283 283
      * Register the aliases from this module.
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
     protected function registerFiles(): void
303 303
     {
304 304
         foreach ($this->get('files', []) as $file) {
305
-            include $this->path . '/' . $file;
305
+            include $this->path.'/'.$file;
306 306
         }
307 307
     }
308 308
 
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
      */
408 408
     public function getExtraPath(string $path) : string
409 409
     {
410
-        return $this->getPath() . '/' . $path;
410
+        return $this->getPath().'/'.$path;
411 411
     }
412 412
 
413 413
     /**
Please login to merge, or discard this patch.
src/LumenModulesServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function setupStubPath()
33 33
     {
34
-        Stub::setBasePath(__DIR__ . '/Commands/stubs');
34
+        Stub::setBasePath(__DIR__.'/Commands/stubs');
35 35
 
36 36
         if (app('modules')->config('stubs.enabled') === true) {
37 37
             Stub::setBasePath(app('modules')->config('stubs.path'));
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
      */
44 44
     protected function registerServices()
45 45
     {
46
-        $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) {
46
+        $this->app->singleton(Contracts\RepositoryInterface::class, function($app) {
47 47
             $path = $app['config']->get('modules.paths.modules');
48 48
 
49 49
             return new Lumen\LumenFileRepository($app, $path);
50 50
         });
51
-        $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) {
51
+        $this->app->singleton(Contracts\ActivatorInterface::class, function($app) {
52 52
             $activator = $app['config']->get('modules.activator');
53
-            $class = $app['config']->get('modules.activators.' . $activator)['class'];
53
+            $class = $app['config']->get('modules.activators.'.$activator)['class'];
54 54
 
55 55
             return new $class($app);
56 56
         });
Please login to merge, or discard this patch.
src/Activators/FileActivator.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             return $this->readJson();
80 80
         }
81 81
 
82
-        return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
82
+        return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function() {
83 83
             return $this->readJson();
84 84
         });
85 85
     }
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
      */
102 102
     private function config(string $key, $default = null)
103 103
     {
104
-        return $this->config->get('modules.activators.file.' . $key, $default);
104
+        return $this->config->get('modules.activators.file.'.$key, $default);
105 105
     }
106 106
 
107 107
     /**
Please login to merge, or discard this patch.
src/Lumen/Module.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
      */
13 13
     public function getCachedServicesPath(): string
14 14
     {
15
-        return Str::replaceLast('services.php', $this->getSnakeName() . '_module.php', $this->app->basePath('storage/app/') . 'services.php');
15
+        return Str::replaceLast('services.php', $this->getSnakeName().'_module.php', $this->app->basePath('storage/app/').'services.php');
16 16
     }
17 17
 
18 18
     /**
Please login to merge, or discard this patch.
src/Support/Migrations/SchemaParser.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public function createField($column, $attributes, $type = 'add')
148 148
     {
149
-        $results = "\t\t\t" . '$table';
149
+        $results = "\t\t\t".'$table';
150 150
 
151 151
         foreach ($attributes as $key => $field) {
152 152
             if (in_array($column, $this->relationshipKeys)) {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             }
157 157
         }
158 158
 
159
-        return $results . ';' . PHP_EOL;
159
+        return $results.';'.PHP_EOL;
160 160
     }
161 161
 
162 162
     /**
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
     protected function addRelationColumn($key, $field, $column)
172 172
     {
173 173
         if ($key === 0) {
174
-            $relatedColumn = Str::snake(class_basename($field)) . '_id';
174
+            $relatedColumn = Str::snake(class_basename($field)).'_id';
175 175
 
176
-            return "->integer('{$relatedColumn}')->unsigned();" . PHP_EOL . "\t\t\t" . "\$table->foreign('{$relatedColumn}')";
176
+            return "->integer('{$relatedColumn}')->unsigned();".PHP_EOL."\t\t\t"."\$table->foreign('{$relatedColumn}')";
177 177
         }
178 178
         if ($key === 1) {
179 179
             return "->references('{$field}')";
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
             return "->on('{$field}')";
183 183
         }
184 184
         if (Str::contains($field, '(')) {
185
-            return '->' . $field;
185
+            return '->'.$field;
186 186
         }
187
-        return '->' . $field . '()';
187
+        return '->'.$field.'()';
188 188
     }
189 189
 
190 190
     /**
@@ -199,18 +199,18 @@  discard block
 block discarded – undo
199 199
     protected function addColumn($key, $field, $column)
200 200
     {
201 201
         if ($this->hasCustomAttribute($column)) {
202
-            return '->' . $field;
202
+            return '->'.$field;
203 203
         }
204 204
 
205 205
         if ($key == 0) {
206
-            return '->' . $field . "('" . $column . "')";
206
+            return '->'.$field."('".$column."')";
207 207
         }
208 208
 
209 209
         if (Str::contains($field, '(')) {
210
-            return '->' . $field;
210
+            return '->'.$field;
211 211
         }
212 212
 
213
-        return '->' . $field . '()';
213
+        return '->'.$field.'()';
214 214
     }
215 215
 
216 216
     /**
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
     protected function removeColumn($key, $field, $column)
226 226
     {
227 227
         if ($this->hasCustomAttribute($column)) {
228
-            return '->' . $field;
228
+            return '->'.$field;
229 229
         }
230 230
 
231
-        return '->dropColumn(' . "'" . $column . "')";
231
+        return '->dropColumn('."'".$column."')";
232 232
     }
233 233
 
234 234
     /**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
      */
254 254
     public function getAttributes($column, $schema)
255 255
     {
256
-        $fields = str_replace($column . ':', '', $schema);
256
+        $fields = str_replace($column.':', '', $schema);
257 257
 
258 258
         return $this->hasCustomAttribute($column) ? $this->getCustomAttribute($column) : explode(':', $fields);
259 259
     }
Please login to merge, or discard this patch.
src/helpers.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! function_exists('module_path')) {
3
+if (!function_exists('module_path')) {
4 4
     function module_path($name, $path = '')
5 5
     {
6 6
         $module = app('modules')->find($name);
7 7
 
8
-        return $module->getPath() . ($path ? DIRECTORY_SEPARATOR . $path : $path);
8
+        return $module->getPath().($path ? DIRECTORY_SEPARATOR . $path : $path);
9 9
     }
10 10
 }
11 11
 
12
-if (! function_exists('config_path')) {
12
+if (!function_exists('config_path')) {
13 13
     /**
14 14
      * Get the configuration path.
15 15
      *
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
      */
19 19
     function config_path($path = '')
20 20
     {
21
-        return app()->basePath() . '/config' . ($path ? DIRECTORY_SEPARATOR . $path : $path);
21
+        return app()->basePath().'/config'.($path ? DIRECTORY_SEPARATOR . $path : $path);
22 22
     }
23 23
 }
24 24
 
25
-if (! function_exists('public_path')) {
25
+if (!function_exists('public_path')) {
26 26
     /**
27 27
      * Get the path to the public folder.
28 28
      *
@@ -31,6 +31,6 @@  discard block
 block discarded – undo
31 31
      */
32 32
     function public_path($path = '')
33 33
     {
34
-        return app()->make('path.public') . ($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path);
34
+        return app()->make('path.public').($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path);
35 35
     }
36 36
 }
Please login to merge, or discard this patch.
src/Generators/ModuleGenerator.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 continue;
330 330
             }
331 331
 
332
-            $path = $this->module->getModulePath($this->getName()) . '/' . $folder->getPath();
332
+            $path = $this->module->getModulePath($this->getName()).'/'.$folder->getPath();
333 333
 
334 334
             $this->filesystem->makeDirectory($path, 0755, true);
335 335
             if (config('modules.stubs.gitkeep')) {
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
      */
346 346
     public function generateGitKeep($path)
347 347
     {
348
-        $this->filesystem->put($path . '/.gitkeep', '');
348
+        $this->filesystem->put($path.'/.gitkeep', '');
349 349
     }
350 350
 
351 351
     /**
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
     public function generateFiles()
355 355
     {
356 356
         foreach ($this->getFiles() as $stub => $file) {
357
-            $path = $this->module->getModulePath($this->getName()) . $file;
357
+            $path = $this->module->getModulePath($this->getName()).$file;
358 358
 
359 359
             if (!$this->filesystem->isDirectory($dir = dirname($path))) {
360 360
                 $this->filesystem->makeDirectory($dir, 0775, true);
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 
382 382
         if (GenerateConfigReader::read('provider')->generate() === true) {
383 383
             $this->console->call('module:make-provider', [
384
-                'name' => $this->getName() . 'ServiceProvider',
384
+                'name' => $this->getName().'ServiceProvider',
385 385
                 'module' => $this->getName(),
386 386
                 '--master' => true,
387 387
             ]);
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 
393 393
         if (GenerateConfigReader::read('controller')->generate() === true) {
394 394
             $this->console->call('module:make-controller', [
395
-                'controller' => $this->getName() . 'Controller',
395
+                'controller' => $this->getName().'Controller',
396 396
                 'module' => $this->getName(),
397 397
             ]);
398 398
         }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     protected function getStubContents($stub)
409 409
     {
410 410
         return (new Stub(
411
-            '/' . $stub . '.stub',
411
+            '/'.$stub.'.stub',
412 412
             $this->getReplacement($stub)
413 413
         )
414 414
         )->render();
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
             }
448 448
         }
449 449
         foreach ($keys as $key) {
450
-            if (method_exists($this, $method = 'get' . ucfirst(Str::studly(strtolower($key))) . 'Replacement')) {
450
+            if (method_exists($this, $method = 'get'.ucfirst(Str::studly(strtolower($key))).'Replacement')) {
451 451
                 $replaces[$key] = $this->$method();
452 452
             } else {
453 453
                 $replaces[$key] = null;
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
      */
463 463
     private function generateModuleJsonFile()
464 464
     {
465
-        $path = $this->module->getModulePath($this->getName()) . 'module.json';
465
+        $path = $this->module->getModulePath($this->getName()).'module.json';
466 466
 
467 467
         if (!$this->filesystem->isDirectory($dir = dirname($path))) {
468 468
             $this->filesystem->makeDirectory($dir, 0775, true);
@@ -479,13 +479,13 @@  discard block
 block discarded – undo
479 479
      */
480 480
     private function cleanModuleJsonFile()
481 481
     {
482
-        $path = $this->module->getModulePath($this->getName()) . 'module.json';
482
+        $path = $this->module->getModulePath($this->getName()).'module.json';
483 483
 
484 484
         $content = $this->filesystem->get($path);
485 485
         $namespace = $this->getModuleNamespaceReplacement();
486 486
         $studlyName = $this->getStudlyNameReplacement();
487 487
 
488
-        $provider = '"' . $namespace . '\\\\' . $studlyName . '\\\\Providers\\\\' . $studlyName . 'ServiceProvider"';
488
+        $provider = '"'.$namespace.'\\\\'.$studlyName.'\\\\Providers\\\\'.$studlyName.'ServiceProvider"';
489 489
 
490 490
         $content = str_replace($provider, '', $content);
491 491
 
Please login to merge, or discard this patch.