Passed
Pull Request — master (#190)
by Arman
02:55
created
src/Console/Commands/ResourceCacheClearCommand.php 1 patch
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -30,212 +30,212 @@
 block discarded – undo
30 30
 class ResourceCacheClearCommand extends QtCommand
31 31
 {
32 32
 
33
-	/**
34
-	 * Command name
35
-	 * @var string
36
-	 */
37
-	protected $name = 'cache:clear';
38
-
39
-	/**
40
-	 * Command description
41
-	 * @var string
42
-	 */
43
-	protected $description = 'Clears resource cache';
44
-
45
-	/**
46
-	 * Command help text
47
-	 * @var string
48
-	 */
49
-	protected $help = 'The command will clear the resource cache';
50
-
51
-	/**
52
-	 * Command options
53
-	 * @var array
54
-	 */
55
-	protected $options = [
56
-		['all', 'all', 'none', ''],
57
-		['type', 't', 'required', ''],
58
-		['module', 'm', 'required', '']
59
-	];
60
-
61
-	/**
62
-	 * @var array
63
-	 */
64
-	protected $types = ['views', 'asserts'];
65
-
66
-	/**
67
-	 * @var array
68
-	 */
69
-	protected $modules;
70
-
71
-	/**
72
-	 * @var string|null
73
-	 */
74
-	protected $type = null;
75
-
76
-	/**
77
-	 * @var string|null
78
-	 */
79
-	protected $module = null;
80
-
81
-	/**
82
-	 * @var string
83
-	 */
84
-	protected $cacheDir;
85
-
86
-	/**
87
-	 * @var object
88
-	 */
89
-	protected $fs;
33
+    /**
34
+     * Command name
35
+     * @var string
36
+     */
37
+    protected $name = 'cache:clear';
38
+
39
+    /**
40
+     * Command description
41
+     * @var string
42
+     */
43
+    protected $description = 'Clears resource cache';
44
+
45
+    /**
46
+     * Command help text
47
+     * @var string
48
+     */
49
+    protected $help = 'The command will clear the resource cache';
50
+
51
+    /**
52
+     * Command options
53
+     * @var array
54
+     */
55
+    protected $options = [
56
+        ['all', 'all', 'none', ''],
57
+        ['type', 't', 'required', ''],
58
+        ['module', 'm', 'required', '']
59
+    ];
60
+
61
+    /**
62
+     * @var array
63
+     */
64
+    protected $types = ['views', 'asserts'];
65
+
66
+    /**
67
+     * @var array
68
+     */
69
+    protected $modules;
70
+
71
+    /**
72
+     * @var string|null
73
+     */
74
+    protected $type = null;
75
+
76
+    /**
77
+     * @var string|null
78
+     */
79
+    protected $module = null;
80
+
81
+    /**
82
+     * @var string
83
+     */
84
+    protected $cacheDir;
85
+
86
+    /**
87
+     * @var object
88
+     */
89
+    protected $fs;
90 90
 
91 91
     /**
92 92
      * @throws BaseException
93 93
      */
94
-	public function exec()
95
-	{
96
-		try {
97
-			$this->importConfig();
98
-			$this->initModule($this->getOption('module'));
99
-			$this->initType($this->getOption('type'));
100
-		}catch (Exception $e){
101
-			$this->error($e->getMessage());
102
-			return;
103
-		}
104
-
105
-		$this->fs = FileSystemFactory::get();
106
-
107
-		if (!$this->fs->isDirectory($this->cacheDir)) {
108
-			$this->error('Cache directory does not exist or is not accessible.');
109
-			return;
110
-		}
111
-
112
-		if ($this->module || $this->type) {
113
-			$this->clearResourceModuleAndType($this->module, $this->type);
114
-		} elseif (!empty($this->getOption('all'))) {
115
-			$this->removeFilesFromDirectory($this->cacheDir);
116
-		} else {
117
-			$this->error('Please specify at least one of the following options: --all, --module=moduleName or --type=typeName!');
118
-			return;
119
-		}
120
-
121
-		$this->info('Resource cache cleared successfully.');
122
-	}
123
-
124
-	/**
125
-	 * @return void
126
-	 */
127
-	private function importModules()
128
-	{
129
-		try {
130
-			if (!config()->has('modules')) {
131
-				config()->import(new Setup('config', 'modules'));
132
-			}
133
-
134
-			if (config()->has('modules') && is_array(config()->get('modules.modules'))){
135
-				$this->modules = array_keys(array_change_key_case(config()->get('modules.modules')));
136
-			}
137
-		} catch (ConfigException|DiException|ReflectionException $e) {
138
-			$this->error($e->getMessage());
139
-			return;
140
-		}
141
-	}
142
-
143
-	/**
144
-	 * @return void
145
-	 * @throws ConfigException
146
-	 * @throws DiException
147
-	 * @throws ReflectionException
148
-	 */
149
-	private function importConfig(): void
150
-	{
151
-		if (!config()->has('view_cache')) {
152
-			config()->import(new Setup('config', 'view_cache'));
153
-		}
154
-
155
-		$this->cacheDir = base_dir() . DS . config()->get('view_cache.cache_dir', 'cache');
156
-	}
157
-
158
-	/**
159
-	 * @param string|null $moduleOption
160
-	 * @return void
161
-	 * @throws Exception
162
-	 */
163
-	private function initModule(?string $moduleOption): void
164
-	{
165
-		if (!empty($moduleOption)) {
166
-			$this->importModules();
167
-			$module = strtolower($moduleOption);
168
-
169
-			if (in_array($module, $this->modules)) {
170
-				$this->module = $module;
171
-			} else {
172
-				throw new Exception('Module {'. $module .'} does not exist.');
173
-			}
174
-		}
175
-	}
176
-
177
-	/**
178
-	 * @param string|null $typeOption
179
-	 * @return void
180
-	 * @throws Exception
181
-	 */
182
-	private function initType(?string $typeOption): void
183
-	{
184
-		if (!empty($typeOption)) {
185
-			$type = strtolower($typeOption);
186
-
187
-			if (in_array($type, $this->types)) {
188
-				$this->type = $type;
189
-			} else {
190
-				throw new Exception('Cache type {'. $type .'} is invalid.');
191
-			}
192
-		}
193
-	}
194
-
195
-	/**
196
-	 * @param string|null $moduleName
197
-	 * @param string|null $type
198
-	 * @return void
199
-	 */
200
-	private function clearResourceModuleAndType(?string $moduleName = null, ?string $type = null): void
201
-	{
202
-		$dir = $this->cacheDir;
203
-
204
-		if ($type) {
205
-			$dir = $dir . DS . strtolower($type);
206
-		}
207
-
208
-		if ($moduleName) {
209
-			if (!$type) {
210
-				$dir = $dir . DS . '*';
211
-			}
212
-
213
-			$dir = $dir . DS . strtolower($moduleName);
214
-		}
215
-
216
-		$this->removeFilesFromDirectory($dir);
217
-	}
218
-
219
-	/**
220
-	 * @param string $dir
221
-	 * @return void
222
-	 */
223
-	private function removeFilesFromDirectory(string $dir): void
224
-	{
225
-		$entries = $this->fs->glob($dir . DS . '*');
226
-
227
-		foreach ($entries as $entry) {
228
-			if ($this->fs->isDirectory($entry)) {
229
-				$this->removeFilesFromDirectory($entry);
230
-
231
-				if ($this->fs->fileName($entry) !== config()->get('view_cache.cache_dir', 'cache') &&
232
-					count($this->fs->glob($entry . DS . '*')) === 0
233
-				) {
234
-					$this->fs->removeDirectory($entry);
235
-				}
236
-			} else {
237
-				$this->fs->remove($entry);
238
-			}
239
-		}
240
-	}
94
+    public function exec()
95
+    {
96
+        try {
97
+            $this->importConfig();
98
+            $this->initModule($this->getOption('module'));
99
+            $this->initType($this->getOption('type'));
100
+        }catch (Exception $e){
101
+            $this->error($e->getMessage());
102
+            return;
103
+        }
104
+
105
+        $this->fs = FileSystemFactory::get();
106
+
107
+        if (!$this->fs->isDirectory($this->cacheDir)) {
108
+            $this->error('Cache directory does not exist or is not accessible.');
109
+            return;
110
+        }
111
+
112
+        if ($this->module || $this->type) {
113
+            $this->clearResourceModuleAndType($this->module, $this->type);
114
+        } elseif (!empty($this->getOption('all'))) {
115
+            $this->removeFilesFromDirectory($this->cacheDir);
116
+        } else {
117
+            $this->error('Please specify at least one of the following options: --all, --module=moduleName or --type=typeName!');
118
+            return;
119
+        }
120
+
121
+        $this->info('Resource cache cleared successfully.');
122
+    }
123
+
124
+    /**
125
+     * @return void
126
+     */
127
+    private function importModules()
128
+    {
129
+        try {
130
+            if (!config()->has('modules')) {
131
+                config()->import(new Setup('config', 'modules'));
132
+            }
133
+
134
+            if (config()->has('modules') && is_array(config()->get('modules.modules'))){
135
+                $this->modules = array_keys(array_change_key_case(config()->get('modules.modules')));
136
+            }
137
+        } catch (ConfigException|DiException|ReflectionException $e) {
138
+            $this->error($e->getMessage());
139
+            return;
140
+        }
141
+    }
142
+
143
+    /**
144
+     * @return void
145
+     * @throws ConfigException
146
+     * @throws DiException
147
+     * @throws ReflectionException
148
+     */
149
+    private function importConfig(): void
150
+    {
151
+        if (!config()->has('view_cache')) {
152
+            config()->import(new Setup('config', 'view_cache'));
153
+        }
154
+
155
+        $this->cacheDir = base_dir() . DS . config()->get('view_cache.cache_dir', 'cache');
156
+    }
157
+
158
+    /**
159
+     * @param string|null $moduleOption
160
+     * @return void
161
+     * @throws Exception
162
+     */
163
+    private function initModule(?string $moduleOption): void
164
+    {
165
+        if (!empty($moduleOption)) {
166
+            $this->importModules();
167
+            $module = strtolower($moduleOption);
168
+
169
+            if (in_array($module, $this->modules)) {
170
+                $this->module = $module;
171
+            } else {
172
+                throw new Exception('Module {'. $module .'} does not exist.');
173
+            }
174
+        }
175
+    }
176
+
177
+    /**
178
+     * @param string|null $typeOption
179
+     * @return void
180
+     * @throws Exception
181
+     */
182
+    private function initType(?string $typeOption): void
183
+    {
184
+        if (!empty($typeOption)) {
185
+            $type = strtolower($typeOption);
186
+
187
+            if (in_array($type, $this->types)) {
188
+                $this->type = $type;
189
+            } else {
190
+                throw new Exception('Cache type {'. $type .'} is invalid.');
191
+            }
192
+        }
193
+    }
194
+
195
+    /**
196
+     * @param string|null $moduleName
197
+     * @param string|null $type
198
+     * @return void
199
+     */
200
+    private function clearResourceModuleAndType(?string $moduleName = null, ?string $type = null): void
201
+    {
202
+        $dir = $this->cacheDir;
203
+
204
+        if ($type) {
205
+            $dir = $dir . DS . strtolower($type);
206
+        }
207
+
208
+        if ($moduleName) {
209
+            if (!$type) {
210
+                $dir = $dir . DS . '*';
211
+            }
212
+
213
+            $dir = $dir . DS . strtolower($moduleName);
214
+        }
215
+
216
+        $this->removeFilesFromDirectory($dir);
217
+    }
218
+
219
+    /**
220
+     * @param string $dir
221
+     * @return void
222
+     */
223
+    private function removeFilesFromDirectory(string $dir): void
224
+    {
225
+        $entries = $this->fs->glob($dir . DS . '*');
226
+
227
+        foreach ($entries as $entry) {
228
+            if ($this->fs->isDirectory($entry)) {
229
+                $this->removeFilesFromDirectory($entry);
230
+
231
+                if ($this->fs->fileName($entry) !== config()->get('view_cache.cache_dir', 'cache') &&
232
+                    count($this->fs->glob($entry . DS . '*')) === 0
233
+                ) {
234
+                    $this->fs->removeDirectory($entry);
235
+                }
236
+            } else {
237
+                $this->fs->remove($entry);
238
+            }
239
+        }
240
+    }
241 241
 }
242 242
\ No newline at end of file
Please login to merge, or discard this patch.
src/Router/ModuleLoader.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
             throw ModuleLoaderException::moduleRoutesNotFound($module);
132 132
         }
133 133
 
134
-        if(empty(self::$moduleRoutes[$module])) {
134
+        if (empty(self::$moduleRoutes[$module])) {
135 135
             self::$moduleRoutes[$module] = $this->fs->require($moduleRoutes, true);
136 136
         }
137 137
 
Please login to merge, or discard this patch.
src/Http/Request/HttpRequest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
         self::$__query = self::$server->query();
103 103
 
104
-        self::$__headers = array_change_key_case((array)getallheaders());
104
+        self::$__headers = array_change_key_case((array) getallheaders());
105 105
 
106 106
         list('params' => $params, 'files' => $files) = self::parsedParams();
107 107
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         $csrfToken = null;
253 253
 
254 254
         if (self::has(Csrf::TOKEN_KEY)) {
255
-            $csrfToken = (string)self::get(Csrf::TOKEN_KEY);
255
+            $csrfToken = (string) self::get(Csrf::TOKEN_KEY);
256 256
         } elseif (self::hasHeader('X-' . Csrf::TOKEN_KEY)) {
257 257
             $csrfToken = self::getHeader('X-' . Csrf::TOKEN_KEY);
258 258
         }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     {
269 269
         $bearerToken = null;
270 270
 
271
-        $authorization = (string)self::getHeader('Authorization');
271
+        $authorization = (string) self::getHeader('Authorization');
272 272
 
273 273
         if (self::hasHeader('Authorization')) {
274 274
             if (preg_match('/Bearer\s(\S+)/', $authorization, $matches)) {
Please login to merge, or discard this patch.
src/Libraries/Encryption/Adapters/AsymmetricEncryptionAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
      */
63 63
     public function encrypt(string $plain): string
64 64
     {
65
-        if(!$this->publicKey) {
65
+        if (!$this->publicKey) {
66 66
             throw CryptorException::publicKeyNotProvided();
67 67
         }
68 68
 
Please login to merge, or discard this patch.
src/Libraries/Auth/Factories/AuthFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@
 block discarded – undo
99 99
         if ($adapter == Auth::API) {
100 100
             $jwt = (new JwtToken())
101 101
                 ->setLeeway(1)
102
-                ->setClaims((array)config()->get('auth.claims'));
102
+                ->setClaims((array) config()->get('auth.claims'));
103 103
         }
104 104
 
105 105
         return new Auth(new $adapterClass($authService, $mailer, $hasher, $jwt));
Please login to merge, or discard this patch.
src/Libraries/Auth/Adapters/ApiAdapter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@
 block discarded – undo
178 178
      */
179 179
     private function getUserFromAccessToken(): ?User
180 180
     {
181
-        $accessToken = base64_decode((string)Request::getAuthorizationBearer());
181
+        $accessToken = base64_decode((string) Request::getAuthorizationBearer());
182 182
         return (new User())->setData($this->jwt->retrieve($accessToken)->fetchData());
183 183
     }
184 184
 
Please login to merge, or discard this patch.
src/Libraries/Storage/Adapters/Dropbox/DropboxApp.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -273,8 +273,8 @@
 block discarded – undo
273 273
             return false;
274 274
         }
275 275
 
276
-        if(isset($message->error)) {
277
-            $error = (array)$message->error;
276
+        if (isset($message->error)) {
277
+            $error = (array) $message->error;
278 278
 
279 279
             if (!isset($error['.tag']) && !in_array($error['.tag'], self::ACCESS_TOKEN_STATUS)) {
280 280
                 return false;
Please login to merge, or discard this patch.
src/Libraries/Validation/Rules/General.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -82,9 +82,9 @@
 block discarded – undo
82 82
         if (!empty($value)) {
83 83
             $captcha = CaptchaFactory::get();
84 84
 
85
-            if (!$captcha->verify($value)){
85
+            if (!$captcha->verify($value)) {
86 86
                 $errorCode = $captcha->getErrorMessage();
87
-                $this->addError($field, 'captcha.'.$errorCode, $param);
87
+                $this->addError($field, 'captcha.' . $errorCode, $param);
88 88
             }
89 89
         }
90 90
     }
Please login to merge, or discard this patch.
src/App/Adapters/ConsoleAppAdapter.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,9 @@
 block discarded – undo
27 27
 use Quantum\Exceptions\BaseException;
28 28
 use ReflectionException;
29 29
 
30
-if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
30
+if (!defined('DS')) {
31
+    define('DS', DIRECTORY_SEPARATOR);
32
+}
31 33
 
32 34
 /**
33 35
  * Class ConsoleAppAdapter
Please login to merge, or discard this patch.