Completed
Pull Request — master (#790)
by
unknown
03:34
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/Activators/FileActivator.php 3 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -8,100 +8,100 @@  discard block
 block discarded – undo
8 8
 
9 9
 class FileActivator implements ActivatorInterface
10 10
 {
11
-	/**
12
-	 * @var string
13
-	 */
14
-	protected $cacheKey;
15
-
16
-	/**
17
-	 * @var string
18
-	 */
19
-	protected $cacheLifetime;
20
-
21
-	/**
22
-	 * Array of modules activation statuses
23
-	 * 
24
-	 * @var array
25
-	 */
26
-	protected $installed;
27
-
28
-	/**
29
-	 * File used to store activation statuses
30
-	 * 
31
-	 * @var string
32
-	 */
33
-	protected $fileInstalled;
34
-
35
-	public function __construct(Container $app)
36
-	{
37
-		$this->cache = $app['cache'];
38
-		$this->files = $app['files'];
39
-		$this->config = $app['config'];
40
-		$this->fileInstalled = $this->config('file');
41
-		$this->cacheKey = $this->config('cache-key');
42
-		$this->cacheLifetime = $this->config('cache-lifetime');
43
-		$this->installed = $this->getCached();
44
-	}
45
-
46
-	/**
47
-	 * Get installed cache
48
-	 * 
49
-	 * @return array
50
-	 */
51
-	protected function getCached()
52
-	{
53
-		if(!$this->config->get('modules.cache.enabled')) return $this->readJson();
11
+    /**
12
+     * @var string
13
+     */
14
+    protected $cacheKey;
15
+
16
+    /**
17
+     * @var string
18
+     */
19
+    protected $cacheLifetime;
20
+
21
+    /**
22
+     * Array of modules activation statuses
23
+     * 
24
+     * @var array
25
+     */
26
+    protected $installed;
27
+
28
+    /**
29
+     * File used to store activation statuses
30
+     * 
31
+     * @var string
32
+     */
33
+    protected $fileInstalled;
34
+
35
+    public function __construct(Container $app)
36
+    {
37
+        $this->cache = $app['cache'];
38
+        $this->files = $app['files'];
39
+        $this->config = $app['config'];
40
+        $this->fileInstalled = $this->config('file');
41
+        $this->cacheKey = $this->config('cache-key');
42
+        $this->cacheLifetime = $this->config('cache-lifetime');
43
+        $this->installed = $this->getCached();
44
+    }
45
+
46
+    /**
47
+     * Get installed cache
48
+     * 
49
+     * @return array
50
+     */
51
+    protected function getCached()
52
+    {
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
-	}
59
-
60
-	/**
61
-	 * Forgets the installed cache
62
-	 */
63
-	protected function forgetCache()
64
-	{
65
-		$this->cache->forget($this->cacheKey);
66
-	}
67
-
68
-	/**
69
-	 * Reads a config parameter
70
-	 * 
71
-	 * @param  string $key     [description]
72
-	 * @param  $default
73
-	 * @return mixed
74
-	 */
75
-	protected function config(string $key, $default = null)
58
+    }
59
+
60
+    /**
61
+     * Forgets the installed cache
62
+     */
63
+    protected function forgetCache()
64
+    {
65
+        $this->cache->forget($this->cacheKey);
66
+    }
67
+
68
+    /**
69
+     * Reads a config parameter
70
+     * 
71
+     * @param  string $key     [description]
72
+     * @param  $default
73
+     * @return mixed
74
+     */
75
+    protected function config(string $key, $default = null)
76 76
     {
77 77
         return $this->config->get('modules.activators.file.' . $key, $default);
78 78
     }
79 79
 
80
-	/**
81
-	 * Reads the installed json file
82
-	 * 
83
-	 * @return array
84
-	 */
85
-	protected function readJson()
86
-	{
87
-		if(!$this->files->exists($this->fileInstalled)) return [];
88
-		return json_decode($this->files->get($this->fileInstalled), true);
89
-	}
90
-
91
-	/**
92
-	 * Writes the installed json file
93
-	 */
94
-	protected function writeJson()
95
-	{
96
-		$this->files->put($this->fileInstalled, json_encode($this->installed, JSON_PRETTY_PRINT));
97
-	}
98
-
99
-	/**
80
+    /**
81
+     * Reads the installed json file
82
+     * 
83
+     * @return array
84
+     */
85
+    protected function readJson()
86
+    {
87
+        if(!$this->files->exists($this->fileInstalled)) return [];
88
+        return json_decode($this->files->get($this->fileInstalled), true);
89
+    }
90
+
91
+    /**
92
+     * Writes the installed json file
93
+     */
94
+    protected function writeJson()
95
+    {
96
+        $this->files->put($this->fileInstalled, json_encode($this->installed, JSON_PRETTY_PRINT));
97
+    }
98
+
99
+    /**
100 100
      * @inheritDoc
101 101
      */
102 102
     public function enable(Module $module)
103 103
     {
104
-    	$this->setActiveByName($module->getName(), 1);
104
+        $this->setActiveByName($module->getName(), 1);
105 105
     }
106 106
 
107 107
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function disable(Module $module)
111 111
     {
112
-		$this->setActiveByName($module->getName(), 0);
112
+        $this->setActiveByName($module->getName(), 0);
113 113
     }
114 114
 
115 115
     /**
@@ -117,8 +117,8 @@  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;
121
-    	return $this->installed[$module->getName()] == $status;
120
+        if(!isset($this->installed[$module->getName()])) return false;
121
+        return $this->installed[$module->getName()] == $status;
122 122
     }
123 123
 
124 124
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function setActive(Module $module, $active)
128 128
     {
129
-    	$this->setActiveByName($module->getName(), $active);
129
+        $this->setActiveByName($module->getName(), $active);
130 130
     }
131 131
 
132 132
     /**
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
      */
135 135
     public function setActiveByName(string $name, $status)
136 136
     {
137
-    	$this->installed[$name] = (int)$status;
138
-    	$this->writeJson();
139
-    	$this->forgetCache();
137
+        $this->installed[$name] = (int)$status;
138
+        $this->writeJson();
139
+        $this->forgetCache();
140 140
     }
141 141
 
142 142
     /**
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function delete(Module $module)
146 146
     {
147
-    	if(!isset($this->installed[$module->getName()])) return;
148
-    	unset($this->installed[$module->getName()]);
149
-    	$this->writeJson();
150
-    	$this->forgetCache();
147
+        if(!isset($this->installed[$module->getName()])) return;
148
+        unset($this->installed[$module->getName()]);
149
+        $this->writeJson();
150
+        $this->forgetCache();
151 151
     }
152 152
 }
Please login to merge, or discard this patch.
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.
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.