Completed
Pull Request — master (#790)
by
unknown
03:15
created
src/Commands/RouteProviderMakeCommand.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
         $generatorPath = GenerateConfigReader::read('provider');
88 88
 
89
-        return $path . $generatorPath->getPath() . '/' . $this->getFileName() . '.php';
89
+        return $path.$generatorPath->getPath().'/'.$this->getFileName().'.php';
90 90
     }
91 91
 
92 92
     /**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     protected function getWebRoutesPath()
96 96
     {
97
-        return '/' . $this->laravel['modules']->config('stubs.files.routes/web', 'Routes/web.php');
97
+        return '/'.$this->laravel['modules']->config('stubs.files.routes/web', 'Routes/web.php');
98 98
     }
99 99
 
100 100
     /**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     protected function getApiRoutesPath()
104 104
     {
105
-        return '/' . $this->laravel['modules']->config('stubs.files.routes/api', 'Routes/api.php');
105
+        return '/'.$this->laravel['modules']->config('stubs.files.routes/api', 'Routes/api.php');
106 106
     }
107 107
 
108 108
     public function getDefaultNamespace() : string
Please login to merge, or discard this patch.
src/Module.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     {
198 198
         $lowerName = $this->getLowerName();
199 199
 
200
-        $langPath = $this->getPath() . '/Resources/lang';
200
+        $langPath = $this->getPath().'/Resources/lang';
201 201
 
202 202
         if (is_dir($langPath)) {
203 203
             $this->loadTranslationsFrom($langPath, $lowerName);
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
             $file = 'module.json';
218 218
         }
219 219
 
220
-        return Arr::get($this->moduleJson, $file, function () use ($file) {
221
-            return $this->moduleJson[$file] = new Json($this->getPath() . '/' . $file, $this->files);
220
+        return Arr::get($this->moduleJson, $file, function() use ($file) {
221
+            return $this->moduleJson[$file] = new Json($this->getPath().'/'.$file, $this->files);
222 222
         });
223 223
     }
224 224
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
      */
272 272
     protected function fireEvent($event)
273 273
     {
274
-        $this->app['events']->dispatch(sprintf('modules.%s.' . $event, $this->getLowerName()), [$this]);
274
+        $this->app['events']->dispatch(sprintf('modules.%s.'.$event, $this->getLowerName()), [$this]);
275 275
     }
276 276
     /**
277 277
      * Register the aliases from this module.
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
     protected function registerFiles()
297 297
     {
298 298
         foreach ($this->get('files', []) as $file) {
299
-            include $this->path . '/' . $file;
299
+            include $this->path.'/'.$file;
300 300
         }
301 301
     }
302 302
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
      */
400 400
     public function getExtraPath(string $path) : string
401 401
     {
402
-        return $this->getPath() . '/' . $path;
402
+        return $this->getPath().'/'.$path;
403 403
     }
404 404
 
405 405
     /**
Please login to merge, or discard this patch.
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.
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
     }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     {
289 289
         $modules = $this->allEnabled();
290 290
 
291
-        uasort($modules, function (Module $a, Module $b) use ($direction) {
291
+        uasort($modules, function(Module $a, Module $b) use ($direction) {
292 292
             if ($a->order == $b->order) {
293 293
                 return 0;
294 294
             }
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
     public function getModulePath($module)
428 428
     {
429 429
         try {
430
-            return $this->findOrFail($module)->getPath() . '/';
430
+            return $this->findOrFail($module)->getPath().'/';
431 431
         } catch (ModuleNotFoundException $e) {
432
-            return $this->getPath() . '/' . Str::studly($module) . '/';
432
+            return $this->getPath().'/'.Str::studly($module).'/';
433 433
         }
434 434
     }
435 435
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
      */
443 443
     public function assetPath($module) : string
444 444
     {
445
-        return $this->config('paths.assets') . '/' . $module;
445
+        return $this->config('paths.assets').'/'.$module;
446 446
     }
447 447
 
448 448
     /**
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      */
451 451
     public function config(string $key, $default = null)
452 452
     {
453
-        return $this->config->get('modules.' . $key, $default);
453
+        return $this->config->get('modules.'.$key, $default);
454 454
     }
455 455
 
456 456
     /**
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
         }
541 541
         list($name, $url) = explode(':', $asset);
542 542
 
543
-        $baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
543
+        $baseUrl = str_replace(public_path().DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
544 544
 
545
-        $url = $this->url->asset($baseUrl . "/{$name}/" . $url);
545
+        $url = $this->url->asset($baseUrl."/{$name}/".$url);
546 546
 
547 547
         return str_replace(['http://', 'https://'], '//', $url);
548 548
     }
Please login to merge, or discard this patch.
src/Activators/FileActivator.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	protected function getCached()
52 52
 	{
53
-		if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
53
+		if (!$this->config->get('modules.cache.enabled')) return $this->readJson();
54 54
 		
55
-		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
55
+		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function() {
56 56
             return $this->readJson();
57 57
         });
58 58
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 */
75 75
 	protected function config(string $key, $default = null)
76 76
     {
77
-        return $this->config->get('modules.activators.file.' . $key, $default);
77
+        return $this->config->get('modules.activators.file.'.$key, $default);
78 78
     }
79 79
 
80 80
 	/**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	protected function readJson()
86 86
 	{
87
-		if(!$this->files->exists($this->fileInstalled)) return [];
87
+		if (!$this->files->exists($this->fileInstalled)) return [];
88 88
 		return json_decode($this->files->get($this->fileInstalled), true);
89 89
 	}
90 90
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      */
118 118
     public function isStatus(Module $module, $status)
119 119
     {
120
-    	if(!isset($this->installed[$module->getName()])) return false;
120
+    	if (!isset($this->installed[$module->getName()])) return false;
121 121
     	return $this->installed[$module->getName()] == $status;
122 122
     }
123 123
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function setActiveByName(string $name, $status)
136 136
     {
137
-    	$this->installed[$name] = (int)$status;
137
+    	$this->installed[$name] = (int) $status;
138 138
     	$this->writeJson();
139 139
     	$this->forgetCache();
140 140
     }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function delete(Module $module)
146 146
     {
147
-    	if(!isset($this->installed[$module->getName()])) return;
147
+    	if (!isset($this->installed[$module->getName()])) return;
148 148
     	unset($this->installed[$module->getName()]);
149 149
     	$this->writeJson();
150 150
     	$this->forgetCache();
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -50,7 +50,9 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	protected function getCached()
52 52
 	{
53
-		if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
53
+		if(!$this->config->get('modules.cache.enabled')) {
54
+		    return $this->readJson();
55
+		}
54 56
 		
55 57
 		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
56 58
             return $this->readJson();
@@ -84,7 +86,9 @@  discard block
 block discarded – undo
84 86
 	 */
85 87
 	protected function readJson()
86 88
 	{
87
-		if(!$this->files->exists($this->fileInstalled)) return [];
89
+		if(!$this->files->exists($this->fileInstalled)) {
90
+		    return [];
91
+		}
88 92
 		return json_decode($this->files->get($this->fileInstalled), true);
89 93
 	}
90 94
 
@@ -117,7 +121,9 @@  discard block
 block discarded – undo
117 121
      */
118 122
     public function isStatus(Module $module, $status)
119 123
     {
120
-    	if(!isset($this->installed[$module->getName()])) return false;
124
+    	if(!isset($this->installed[$module->getName()])) {
125
+    	    return false;
126
+    	}
121 127
     	return $this->installed[$module->getName()] == $status;
122 128
     }
123 129
 
@@ -144,7 +150,9 @@  discard block
 block discarded – undo
144 150
      */
145 151
     public function delete(Module $module)
146 152
     {
147
-    	if(!isset($this->installed[$module->getName()])) return;
153
+    	if(!isset($this->installed[$module->getName()])) {
154
+    	    return;
155
+    	}
148 156
     	unset($this->installed[$module->getName()]);
149 157
     	$this->writeJson();
150 158
     	$this->forgetCache();
Please login to merge, or discard this patch.
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -11,120 +11,120 @@  discard block
 block discarded – undo
11 11
 
12 12
 class FileActivator implements ActivatorInterface
13 13
 {
14
-	/**
15
-	 * Laravel cache instance
16
-	 * 
17
-	 * @var CacheManager
18
-	 */
19
-	protected $cache;
20
-
21
-	/**
22
-	 * Laravel Filesystem instance
23
-	 * 
24
-	 * @var Filesystem
25
-	 */
26
-	protected $files;
27
-
28
-	/**
29
-	 * Laravel config instance
30
-	 * @var Config
31
-	 */
32
-	protected $config;
33
-
34
-	/**
35
-	 * @var string
36
-	 */
37
-	protected $cacheKey;
38
-
39
-	/**
40
-	 * @var string
41
-	 */
42
-	protected $cacheLifetime;
43
-
44
-	/**
45
-	 * Array of modules activation statuses
46
-	 * 
47
-	 * @var array
48
-	 */
49
-	protected $installed;
50
-
51
-	/**
52
-	 * File used to store activation statuses
53
-	 * 
54
-	 * @var string
55
-	 */
56
-	protected $fileInstalled;
57
-
58
-	public function __construct(Container $app)
59
-	{
60
-		$this->cache = $app['cache'];
61
-		$this->files = $app['files'];
62
-		$this->config = $app['config'];
63
-		$this->fileInstalled = $this->config('file');
64
-		$this->cacheKey = $this->config('cache-key');
65
-		$this->cacheLifetime = $this->config('cache-lifetime');
66
-		$this->installed = $this->getCached();
67
-	}
68
-
69
-	/**
70
-	 * Get installed cache
71
-	 * 
72
-	 * @return array
73
-	 */
74
-	protected function getCached()
75
-	{
76
-		if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
14
+    /**
15
+     * Laravel cache instance
16
+     * 
17
+     * @var CacheManager
18
+     */
19
+    protected $cache;
20
+
21
+    /**
22
+     * Laravel Filesystem instance
23
+     * 
24
+     * @var Filesystem
25
+     */
26
+    protected $files;
27
+
28
+    /**
29
+     * Laravel config instance
30
+     * @var Config
31
+     */
32
+    protected $config;
33
+
34
+    /**
35
+     * @var string
36
+     */
37
+    protected $cacheKey;
38
+
39
+    /**
40
+     * @var string
41
+     */
42
+    protected $cacheLifetime;
43
+
44
+    /**
45
+     * Array of modules activation statuses
46
+     * 
47
+     * @var array
48
+     */
49
+    protected $installed;
50
+
51
+    /**
52
+     * File used to store activation statuses
53
+     * 
54
+     * @var string
55
+     */
56
+    protected $fileInstalled;
57
+
58
+    public function __construct(Container $app)
59
+    {
60
+        $this->cache = $app['cache'];
61
+        $this->files = $app['files'];
62
+        $this->config = $app['config'];
63
+        $this->fileInstalled = $this->config('file');
64
+        $this->cacheKey = $this->config('cache-key');
65
+        $this->cacheLifetime = $this->config('cache-lifetime');
66
+        $this->installed = $this->getCached();
67
+    }
68
+
69
+    /**
70
+     * Get installed cache
71
+     * 
72
+     * @return array
73
+     */
74
+    protected function getCached()
75
+    {
76
+        if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
77 77
 		
78
-		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
78
+        return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
79 79
             return $this->readJson();
80 80
         });
81
-	}
82
-
83
-	/**
84
-	 * Forgets the installed cache
85
-	 */
86
-	protected function forgetCache()
87
-	{
88
-		$this->cache->forget($this->cacheKey);
89
-	}
90
-
91
-	/**
92
-	 * Reads a config parameter
93
-	 * 
94
-	 * @param  string $key     [description]
95
-	 * @param  $default
96
-	 * @return mixed
97
-	 */
98
-	protected function config(string $key, $default = null)
81
+    }
82
+
83
+    /**
84
+     * Forgets the installed cache
85
+     */
86
+    protected function forgetCache()
87
+    {
88
+        $this->cache->forget($this->cacheKey);
89
+    }
90
+
91
+    /**
92
+     * Reads a config parameter
93
+     * 
94
+     * @param  string $key     [description]
95
+     * @param  $default
96
+     * @return mixed
97
+     */
98
+    protected function config(string $key, $default = null)
99 99
     {
100 100
         return $this->config->get('modules.activators.file.' . $key, $default);
101 101
     }
102 102
 
103
-	/**
104
-	 * Reads the installed json file
105
-	 * 
106
-	 * @return array
107
-	 */
108
-	protected function readJson()
109
-	{
110
-		if(!$this->files->exists($this->fileInstalled)) return [];
111
-		return json_decode($this->files->get($this->fileInstalled), true);
112
-	}
113
-
114
-	/**
115
-	 * Writes the installed json file
116
-	 */
117
-	protected function writeJson()
118
-	{
119
-		$this->files->put($this->fileInstalled, json_encode($this->installed, JSON_PRETTY_PRINT));
120
-	}
121
-
122
-	/**
103
+    /**
104
+     * Reads the installed json file
105
+     * 
106
+     * @return array
107
+     */
108
+    protected function readJson()
109
+    {
110
+        if(!$this->files->exists($this->fileInstalled)) return [];
111
+        return json_decode($this->files->get($this->fileInstalled), true);
112
+    }
113
+
114
+    /**
115
+     * Writes the installed json file
116
+     */
117
+    protected function writeJson()
118
+    {
119
+        $this->files->put($this->fileInstalled, json_encode($this->installed, JSON_PRETTY_PRINT));
120
+    }
121
+
122
+    /**
123 123
      * @inheritDoc
124 124
      */
125 125
     public function enable(Module $module)
126 126
     {
127
-    	$this->setActiveByName($module->getName(), 1);
127
+        $this->setActiveByName($module->getName(), 1);
128 128
     }
129 129
 
130 130
     /**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function disable(Module $module)
134 134
     {
135
-		$this->setActiveByName($module->getName(), 0);
135
+        $this->setActiveByName($module->getName(), 0);
136 136
     }
137 137
 
138 138
     /**
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
      */
141 141
     public function isStatus(Module $module, $status)
142 142
     {
143
-    	if(!isset($this->installed[$module->getName()])) return false;
144
-    	return $this->installed[$module->getName()] == $status;
143
+        if(!isset($this->installed[$module->getName()])) return false;
144
+        return $this->installed[$module->getName()] == $status;
145 145
     }
146 146
 
147 147
     /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function setActive(Module $module, $active)
151 151
     {
152
-    	$this->setActiveByName($module->getName(), $active);
152
+        $this->setActiveByName($module->getName(), $active);
153 153
     }
154 154
 
155 155
     /**
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
      */
158 158
     public function setActiveByName(string $name, $status)
159 159
     {
160
-    	$this->installed[$name] = (int)$status;
161
-    	$this->writeJson();
162
-    	$this->forgetCache();
160
+        $this->installed[$name] = (int)$status;
161
+        $this->writeJson();
162
+        $this->forgetCache();
163 163
     }
164 164
 
165 165
     /**
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
      */
168 168
     public function delete(Module $module)
169 169
     {
170
-    	if(!isset($this->installed[$module->getName()])) return;
171
-    	unset($this->installed[$module->getName()]);
172
-    	$this->writeJson();
173
-    	$this->forgetCache();
170
+        if(!isset($this->installed[$module->getName()])) return;
171
+        unset($this->installed[$module->getName()]);
172
+        $this->writeJson();
173
+        $this->forgetCache();
174 174
     }
175 175
 }
Please login to merge, or discard this patch.
src/LaravelModulesServiceProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  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
-        $this->app->booted(function ($app) {
36
+        $this->app->booted(function($app) {
37 37
             /** @var RepositoryInterface $moduleRepository */
38 38
             $moduleRepository = $app[RepositoryInterface::class];
39 39
             if ($moduleRepository->config('stubs.enabled') === true) {
@@ -47,14 +47,14 @@  discard block
 block discarded – undo
47 47
      */
48 48
     protected function registerServices()
49 49
     {
50
-        $this->app->singleton(Contracts\RepositoryInterface::class, function ($app) {
50
+        $this->app->singleton(Contracts\RepositoryInterface::class, function($app) {
51 51
             $path = $app['config']->get('modules.paths.modules');
52 52
 
53 53
             return new Laravel\LaravelFileRepository($app, $path);
54 54
         });
55
-        $this->app->singleton(Contracts\ActivatorInterface::class, function ($app) {
55
+        $this->app->singleton(Contracts\ActivatorInterface::class, function($app) {
56 56
             $activator = $app['config']->get('modules.activator');
57
-            $class = $app['config']->get('modules.activators.' . $activator)['class'];
57
+            $class = $app['config']->get('modules.activators.'.$activator)['class'];
58 58
 
59 59
             return new $class($app);
60 60
         });
Please login to merge, or discard this patch.