Completed
Pull Request — master (#790)
by
unknown
03:19
created
src/Activators/FileActivator.php 1 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.