Completed
Pull Request — master (#790)
by
unknown
03:36 queued 42s
created
src/Module.php 1 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/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.
src/Activators/FileActivator.php 3 patches
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -11,144 +11,144 @@  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
-	 * 
31
-	 * @var Config
32
-	 */
33
-	protected $config;
34
-
35
-	/**
36
-	 * @var string
37
-	 */
38
-	protected $cacheKey;
39
-
40
-	/**
41
-	 * @var string
42
-	 */
43
-	protected $cacheLifetime;
44
-
45
-	/**
46
-	 * Array of modules activation statuses
47
-	 * 
48
-	 * @var array
49
-	 */
50
-	protected $modulesStatuses;
51
-
52
-	/**
53
-	 * File used to store activation statuses
54
-	 * 
55
-	 * @var string
56
-	 */
57
-	protected $statusesFile;
58
-
59
-	public function __construct(Container $app)
60
-	{
61
-		$this->cache = $app['cache'];
62
-		$this->files = $app['files'];
63
-		$this->config = $app['config'];
64
-		$this->statusesFile = $this->config('statuses-file');
65
-		$this->cacheKey = $this->config('cache-key');
66
-		$this->cacheLifetime = $this->config('cache-lifetime');
67
-		$this->modulesStatuses = $this->getModulesStatuses();
68
-	}
69
-
70
-	/**
71
-	 * Get modules statuses, either from the cache or 
72
-	 * from the json statuses file if the cache is disabled.
73
-	 * 
74
-	 * @return array
75
-	 */
76
-	private function getModulesStatuses()
77
-	{
78
-		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
+     * 
31
+     * @var Config
32
+     */
33
+    protected $config;
34
+
35
+    /**
36
+     * @var string
37
+     */
38
+    protected $cacheKey;
39
+
40
+    /**
41
+     * @var string
42
+     */
43
+    protected $cacheLifetime;
44
+
45
+    /**
46
+     * Array of modules activation statuses
47
+     * 
48
+     * @var array
49
+     */
50
+    protected $modulesStatuses;
51
+
52
+    /**
53
+     * File used to store activation statuses
54
+     * 
55
+     * @var string
56
+     */
57
+    protected $statusesFile;
58
+
59
+    public function __construct(Container $app)
60
+    {
61
+        $this->cache = $app['cache'];
62
+        $this->files = $app['files'];
63
+        $this->config = $app['config'];
64
+        $this->statusesFile = $this->config('statuses-file');
65
+        $this->cacheKey = $this->config('cache-key');
66
+        $this->cacheLifetime = $this->config('cache-lifetime');
67
+        $this->modulesStatuses = $this->getModulesStatuses();
68
+    }
69
+
70
+    /**
71
+     * Get modules statuses, either from the cache or 
72
+     * from the json statuses file if the cache is disabled.
73
+     * 
74
+     * @return array
75
+     */
76
+    private function getModulesStatuses()
77
+    {
78
+        if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
79 79
 		
80
-		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
80
+        return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
81 81
             return $this->readJson();
82 82
         });
83
-	}
84
-
85
-	/**
86
-	 * Flushes the modules activation statuses cache
87
-	 */
88
-	private function flushCache()
89
-	{
90
-		$this->cache->forget($this->cacheKey);
91
-	}
92
-
93
-	/**
94
-	 * Reads a config parameter
95
-	 * 
96
-	 * @param  string $key     [description]
97
-	 * @param  $default
98
-	 * @return mixed
99
-	 */
100
-	private function config(string $key, $default = null)
83
+    }
84
+
85
+    /**
86
+     * Flushes the modules activation statuses cache
87
+     */
88
+    private function flushCache()
89
+    {
90
+        $this->cache->forget($this->cacheKey);
91
+    }
92
+
93
+    /**
94
+     * Reads a config parameter
95
+     * 
96
+     * @param  string $key     [description]
97
+     * @param  $default
98
+     * @return mixed
99
+     */
100
+    private function config(string $key, $default = null)
101 101
     {
102 102
         return $this->config->get('modules.activators.file.' . $key, $default);
103 103
     }
104 104
 
105
-	/**
106
-	 * Reads the json file that contains the activation statuses.
107
-	 * 
108
-	 * @return array
109
-	 */
110
-	private function readJson()
111
-	{
112
-		if(!$this->files->exists($this->statusesFile)) return [];
113
-		return json_decode($this->files->get($this->statusesFile), true);
114
-	}
115
-
116
-	/**
117
-	 * Writes the activation statuses in a file, as json
118
-	 */
119
-	private function writeJson()
120
-	{
121
-		$this->files->put($this->statusesFile, json_encode($this->modulesStatuses, JSON_PRETTY_PRINT));
122
-	}
123
-
124
-	/**
125
-	 * Get the path of the file where statuses are stored
126
-	 * 
127
-	 * @return string
128
-	 */
129
-	public function getStatusesFilePath()
130
-	{
131
-		return $this->statusesFile;
132
-	}
133
-
134
-	/**
135
-	 * @inheritDoc
136
-	 */
137
-	public function reset()
138
-	{
139
-		if($this->files->exists($this->statusesFile)){
140
-			$this->files->delete($this->statusesFile);
141
-		}
142
-		$this->modulesStatuses = [];
143
-		$this->flushCache();
144
-	}
145
-
146
-	/**
105
+    /**
106
+     * Reads the json file that contains the activation statuses.
107
+     * 
108
+     * @return array
109
+     */
110
+    private function readJson()
111
+    {
112
+        if(!$this->files->exists($this->statusesFile)) return [];
113
+        return json_decode($this->files->get($this->statusesFile), true);
114
+    }
115
+
116
+    /**
117
+     * Writes the activation statuses in a file, as json
118
+     */
119
+    private function writeJson()
120
+    {
121
+        $this->files->put($this->statusesFile, json_encode($this->modulesStatuses, JSON_PRETTY_PRINT));
122
+    }
123
+
124
+    /**
125
+     * Get the path of the file where statuses are stored
126
+     * 
127
+     * @return string
128
+     */
129
+    public function getStatusesFilePath()
130
+    {
131
+        return $this->statusesFile;
132
+    }
133
+
134
+    /**
135
+     * @inheritDoc
136
+     */
137
+    public function reset()
138
+    {
139
+        if($this->files->exists($this->statusesFile)){
140
+            $this->files->delete($this->statusesFile);
141
+        }
142
+        $this->modulesStatuses = [];
143
+        $this->flushCache();
144
+    }
145
+
146
+    /**
147 147
      * @inheritDoc
148 148
      */
149 149
     public function enable(Module $module)
150 150
     {
151
-    	$this->setActiveByName($module->getName(), true);
151
+        $this->setActiveByName($module->getName(), true);
152 152
     }
153 153
 
154 154
     /**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function disable(Module $module)
158 158
     {
159
-		$this->setActiveByName($module->getName(), false);
159
+        $this->setActiveByName($module->getName(), false);
160 160
     }
161 161
 
162 162
     /**
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function isStatus(Module $module, bool $status): bool
166 166
     {
167
-    	if(!isset($this->modulesStatuses[$module->getName()])){
168
-    		return $status === false;
169
-    	}
170
-    	return $this->modulesStatuses[$module->getName()] === $status;
167
+        if(!isset($this->modulesStatuses[$module->getName()])){
168
+            return $status === false;
169
+        }
170
+        return $this->modulesStatuses[$module->getName()] === $status;
171 171
     }
172 172
 
173 173
     /**
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
      */
176 176
     public function setActive(Module $module, bool $active)
177 177
     {
178
-    	$this->setActiveByName($module->getName(), $active);
178
+        $this->setActiveByName($module->getName(), $active);
179 179
     }
180 180
 
181 181
     /**
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
      */
184 184
     public function setActiveByName(string $name, bool $status)
185 185
     {
186
-    	$this->modulesStatuses[$name] = $status;
187
-    	$this->writeJson();
188
-    	$this->flushCache();
186
+        $this->modulesStatuses[$name] = $status;
187
+        $this->writeJson();
188
+        $this->flushCache();
189 189
     }
190 190
 
191 191
     /**
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function delete(Module $module)
195 195
     {
196
-    	if(!isset($this->modulesStatuses[$module->getName()])) return;
197
-    	unset($this->modulesStatuses[$module->getName()]);
198
-    	$this->writeJson();
199
-    	$this->flushCache();
196
+        if(!isset($this->modulesStatuses[$module->getName()])) return;
197
+        unset($this->modulesStatuses[$module->getName()]);
198
+        $this->writeJson();
199
+        $this->flushCache();
200 200
     }
201 201
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	private function getModulesStatuses()
77 77
 	{
78
-		if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
78
+		if (!$this->config->get('modules.cache.enabled')) return $this->readJson();
79 79
 		
80
-		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
80
+		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function() {
81 81
             return $this->readJson();
82 82
         });
83 83
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	private function config(string $key, $default = null)
101 101
     {
102
-        return $this->config->get('modules.activators.file.' . $key, $default);
102
+        return $this->config->get('modules.activators.file.'.$key, $default);
103 103
     }
104 104
 
105 105
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	private function readJson()
111 111
 	{
112
-		if(!$this->files->exists($this->statusesFile)) return [];
112
+		if (!$this->files->exists($this->statusesFile)) return [];
113 113
 		return json_decode($this->files->get($this->statusesFile), true);
114 114
 	}
115 115
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 */
137 137
 	public function reset()
138 138
 	{
139
-		if($this->files->exists($this->statusesFile)){
139
+		if ($this->files->exists($this->statusesFile)) {
140 140
 			$this->files->delete($this->statusesFile);
141 141
 		}
142 142
 		$this->modulesStatuses = [];
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function isStatus(Module $module, bool $status): bool
166 166
     {
167
-    	if(!isset($this->modulesStatuses[$module->getName()])){
167
+    	if (!isset($this->modulesStatuses[$module->getName()])) {
168 168
     		return $status === false;
169 169
     	}
170 170
     	return $this->modulesStatuses[$module->getName()] === $status;
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function delete(Module $module)
195 195
     {
196
-    	if(!isset($this->modulesStatuses[$module->getName()])) return;
196
+    	if (!isset($this->modulesStatuses[$module->getName()])) return;
197 197
     	unset($this->modulesStatuses[$module->getName()]);
198 198
     	$this->writeJson();
199 199
     	$this->flushCache();
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,7 +75,9 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	private function getModulesStatuses()
77 77
 	{
78
-		if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
78
+		if(!$this->config->get('modules.cache.enabled')) {
79
+		    return $this->readJson();
80
+		}
79 81
 		
80 82
 		return $this->cache->remember($this->cacheKey, $this->cacheLifetime, function () {
81 83
             return $this->readJson();
@@ -109,7 +111,9 @@  discard block
 block discarded – undo
109 111
 	 */
110 112
 	private function readJson()
111 113
 	{
112
-		if(!$this->files->exists($this->statusesFile)) return [];
114
+		if(!$this->files->exists($this->statusesFile)) {
115
+		    return [];
116
+		}
113 117
 		return json_decode($this->files->get($this->statusesFile), true);
114 118
 	}
115 119
 
@@ -193,7 +197,9 @@  discard block
 block discarded – undo
193 197
      */
194 198
     public function delete(Module $module)
195 199
     {
196
-    	if(!isset($this->modulesStatuses[$module->getName()])) return;
200
+    	if(!isset($this->modulesStatuses[$module->getName()])) {
201
+    	    return;
202
+    	}
197 203
     	unset($this->modulesStatuses[$module->getName()]);
198 204
     	$this->writeJson();
199 205
     	$this->flushCache();
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.