@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | protected $service; |
17 | 17 | |
18 | - public function __construct(?string $name = null, array $data = [], string $dataName = '') |
|
18 | + public function __construct(?string $name = null, array $data = [ ], string $dataName = '') |
|
19 | 19 | { |
20 | 20 | parent::__construct($name, $data, $dataName); |
21 | 21 | $this->service = new BootstrapRegistrarService(); |
@@ -38,14 +38,14 @@ |
||
38 | 38 | $user = $this->auth0Repository->getUserByDecodedJWT($tokenInfo); |
39 | 39 | |
40 | 40 | if (!$user) { |
41 | - return response()->json(['error' => 'Unauthorized user.'], 401); |
|
41 | + return response()->json([ 'error' => 'Unauthorized user.' ], 401); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | \Auth::login($user); |
45 | 45 | } catch (InvalidTokenException $e) { |
46 | - return response()->json(['error' => 'Invalid or no token set.'], 401); |
|
46 | + return response()->json([ 'error' => 'Invalid or no token set.' ], 401); |
|
47 | 47 | } catch (CoreException $e) { |
48 | - return response()->json(['error' => $e->getMessage()], 401); |
|
48 | + return response()->json([ 'error' => $e->getMessage() ], 401); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return $next($request); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | private function getUserTokenData(): \stdClass |
29 | 29 | { |
30 | - return Cache::remember('testing:http_access_token', 60, function () { |
|
30 | + return Cache::remember('testing:http_access_token', 60, function() { |
|
31 | 31 | $httpClient = new Client(); |
32 | 32 | $response = $httpClient->post(config('laravel-auth0.domain').'oauth/token', [ |
33 | 33 | 'form_params' => [ |
@@ -43,19 +43,19 @@ discard block |
||
43 | 43 | }); |
44 | 44 | } |
45 | 45 | |
46 | - protected function http(string $method, string $route, array $payload = []) |
|
46 | + protected function http(string $method, string $route, array $payload = [ ]) |
|
47 | 47 | { |
48 | 48 | return $this->sendRequest($method, $route, $payload, true); |
49 | 49 | } |
50 | 50 | |
51 | - private function sendRequest(string $method, string $route, array $payload = [], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
51 | + private function sendRequest(string $method, string $route, array $payload = [ ], $authenticated = true): \Illuminate\Foundation\Testing\TestResponse |
|
52 | 52 | { |
53 | 53 | return $this->json($method, env('API_URL').'/'.$route, $payload, $authenticated ? [ |
54 | 54 | 'Authorization' => 'Bearer '.$this->getUserTokenData()->id_token, |
55 | - ] : []); |
|
55 | + ] : [ ]); |
|
56 | 56 | } |
57 | 57 | |
58 | - protected function httpNoAuth(string $method, string $route, array $payload = []) |
|
58 | + protected function httpNoAuth(string $method, string $route, array $payload = [ ]) |
|
59 | 59 | { |
60 | 60 | return $this->sendRequest($method, $route, $payload, false); |
61 | 61 | } |
@@ -13,11 +13,11 @@ |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | 'supportsCredentials' => false, |
16 | - 'allowedOrigins' => ['*'], |
|
17 | - 'allowedOriginsPatterns' => [], |
|
18 | - 'allowedHeaders' => ['*'], |
|
19 | - 'allowedMethods' => ['*'], |
|
20 | - 'exposedHeaders' => [], |
|
16 | + 'allowedOrigins' => [ '*' ], |
|
17 | + 'allowedOriginsPatterns' => [ ], |
|
18 | + 'allowedHeaders' => [ '*' ], |
|
19 | + 'allowedMethods' => [ '*' ], |
|
20 | + 'exposedHeaders' => [ ], |
|
21 | 21 | 'maxAge' => 0, |
22 | 22 | |
23 | 23 | ]; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | |
6 | 6 | $factory->define( |
7 | - User::class, function (Faker\Generator $faker) { |
|
7 | + User::class, function(Faker\Generator $faker) { |
|
8 | 8 | return [ |
9 | 9 | 'provider' => 'database', |
10 | 10 | 'name' => $faker->name, |
@@ -18,7 +18,7 @@ |
||
18 | 18 | |
19 | 19 | protected $collection = 'users'; |
20 | 20 | |
21 | - protected $guarded = []; |
|
21 | + protected $guarded = [ ]; |
|
22 | 22 | |
23 | 23 | public function ownerId() |
24 | 24 | { |
@@ -13,7 +13,7 @@ |
||
13 | 13 | */ |
14 | 14 | public function createApplication() |
15 | 15 | { |
16 | - $bootstrapFile = dirname(__FILE__, 5) . '/bootstrap/app.php'; |
|
16 | + $bootstrapFile = dirname(__FILE__, 5).'/bootstrap/app.php'; |
|
17 | 17 | $app = require $bootstrapFile; |
18 | 18 | |
19 | 19 | $app->make(Kernel::class)->bootstrap(); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public static function find($id, $modelClass) |
25 | 25 | { |
26 | - return Cache::remember(self::getCacheName($id, $modelClass), self::getCacheTime(), function () use ($id, $modelClass) { |
|
26 | + return Cache::remember(self::getCacheName($id, $modelClass), self::getCacheTime(), function() use ($id, $modelClass) { |
|
27 | 27 | return $modelClass::find($id); |
28 | 28 | }); |
29 | 29 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function getCacheName($id, $modelClass) |
35 | 35 | { |
36 | - return config('model.cache_prefix') . ':' . strtolower(getShortClassName($modelClass)) . ':' . $id; |
|
36 | + return config('model.cache_prefix').':'.strtolower(getShortClassName($modelClass)).':'.$id; |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | private static function deleteWithPrefix($prefix) |
89 | 89 | { |
90 | 90 | $redis = self::getCacheConnection(); |
91 | - $keyPattern = Cache::getPrefix() . $prefix . '*'; |
|
91 | + $keyPattern = Cache::getPrefix().$prefix.'*'; |
|
92 | 92 | $keys = $redis->keys($keyPattern); |
93 | 93 | $redis->delete($keys); |
94 | 94 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | */ |
113 | 113 | public static function clearModel($modelClass) |
114 | 114 | { |
115 | - $pattern = config('model.cache_prefix') . ':' . strtolower(getShortClassName($modelClass)); |
|
115 | + $pattern = config('model.cache_prefix').':'.strtolower(getShortClassName($modelClass)); |
|
116 | 116 | self::deleteWithPrefix($pattern); |
117 | 117 | } |
118 | 118 |
@@ -100,8 +100,9 @@ |
||
100 | 100 | */ |
101 | 101 | private static function getCacheConnection() |
102 | 102 | { |
103 | - if (config('cache.default') === 'redis') |
|
104 | - return Redis::connection('cache'); |
|
103 | + if (config('cache.default') === 'redis') { |
|
104 | + return Redis::connection('cache'); |
|
105 | + } |
|
105 | 106 | |
106 | 107 | throw new Exception("This action is only possible with redis as cache driver"); |
107 | 108 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private function storeInCache($data) |
66 | 66 | { |
67 | - file_put_contents($this->getCachePath(), '<?php return ' . var_export($data, true) . ';'); |
|
67 | + file_put_contents($this->getCachePath(), '<?php return '.var_export($data, true).';'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | private function getCachePath(): string |
98 | 98 | { |
99 | - return app()->bootstrapPath() . '/cache/' . $this->cacheFile; |
|
99 | + return app()->bootstrapPath().'/cache/'.$this->cacheFile; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,9 +104,9 @@ discard block |
||
104 | 104 | */ |
105 | 105 | private function buildEmptyBootstrapArray() |
106 | 106 | { |
107 | - $bootstrapArray = []; |
|
107 | + $bootstrapArray = [ ]; |
|
108 | 108 | foreach ($this->moduleEntityDirectories as $key => $directory) { |
109 | - $bootstrapArray[$key] = []; |
|
109 | + $bootstrapArray[ $key ] = [ ]; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return $bootstrapArray; |
@@ -130,45 +130,45 @@ discard block |
||
130 | 130 | foreach ($this->getModules() as $module) { |
131 | 131 | foreach ($this->moduleEntityDirectories as $key => $directory) { |
132 | 132 | $directory = ucfirst($directory); |
133 | - $directoryPath = $module->getPath() . '/' . $directory; |
|
134 | - $namespace = 'Modules' . '\\' . $module->getName(); |
|
133 | + $directoryPath = $module->getPath().'/'.$directory; |
|
134 | + $namespace = 'Modules'.'\\'.$module->getName(); |
|
135 | 135 | if (file_exists($directoryPath)) { |
136 | 136 | $files = scandir($directoryPath); |
137 | 137 | foreach ($files as $fileName) { |
138 | 138 | if ($this->hasPhpExtension($fileName)) { |
139 | 139 | $className = basename($fileName, '.php'); |
140 | - $class = $namespace . '\\' . str_replace('/', '\\', $directory) . '\\' . $className; |
|
140 | + $class = $namespace.'\\'.str_replace('/', '\\', $directory).'\\'.$className; |
|
141 | 141 | switch ($key) { |
142 | 142 | case 'commands': |
143 | 143 | try { |
144 | 144 | $command = new $class(); |
145 | 145 | if ($command instanceof Command) { |
146 | - $bootstrap[$key][] = $class; |
|
146 | + $bootstrap[ $key ][ ] = $class; |
|
147 | 147 | } |
148 | 148 | } catch (\Exception $e) { |
149 | 149 | break; |
150 | 150 | } |
151 | 151 | break; |
152 | 152 | case 'routes': |
153 | - $bootstrap[$key][] = $this->buildRouteArray($directoryPath . '/' . $fileName, $namespace); |
|
153 | + $bootstrap[ $key ][ ] = $this->buildRouteArray($directoryPath.'/'.$fileName, $namespace); |
|
154 | 154 | break; |
155 | 155 | case 'configs': |
156 | - $bootstrap[$key][] = $this->buildConfigArray($directoryPath . '/' . $fileName, $module->getName()); |
|
156 | + $bootstrap[ $key ][ ] = $this->buildConfigArray($directoryPath.'/'.$fileName, $module->getName()); |
|
157 | 157 | break; |
158 | 158 | case 'factories': |
159 | - $bootstrap[$key][] = $this->buildDirectoryPathArray($directoryPath); |
|
159 | + $bootstrap[ $key ][ ] = $this->buildDirectoryPathArray($directoryPath); |
|
160 | 160 | break; |
161 | 161 | case 'migrations': |
162 | - $bootstrap[$key][] = $this->buildDirectoryPathArray($directoryPath); |
|
162 | + $bootstrap[ $key ][ ] = $this->buildDirectoryPathArray($directoryPath); |
|
163 | 163 | break; |
164 | 164 | case 'seeders': |
165 | - $bootstrap[$key][] = $class; |
|
165 | + $bootstrap[ $key ][ ] = $class; |
|
166 | 166 | break; |
167 | 167 | case 'models': |
168 | - $bootstrap[$key][] = $class; |
|
168 | + $bootstrap[ $key ][ ] = $class; |
|
169 | 169 | break; |
170 | 170 | case 'policies': |
171 | - $bootstrap[$key][] = $this->buildPolicyArray($class, $namespace); |
|
171 | + $bootstrap[ $key ][ ] = $this->buildPolicyArray($class, $namespace); |
|
172 | 172 | break; |
173 | 173 | default: |
174 | 174 | break; |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | */ |
189 | 189 | private function hasPhpExtension(string $fileName): bool |
190 | 190 | { |
191 | - return strlen($fileName) > 4 && '.php' === ($fileName[-4] . $fileName[-3] . $fileName[-2] . $fileName[-1]); |
|
191 | + return strlen($fileName) > 4 && '.php' === ($fileName[-4 ].$fileName[-3 ].$fileName[-2 ].$fileName[-1 ]); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | $apiDomain = str_replace('http://', '', $apiDomain); |
219 | 219 | $apiDomain = str_replace('https://', '', $apiDomain); |
220 | 220 | $moduleNamespace = $namespace; |
221 | - $moduleName = explode('\\', $moduleNamespace)[1]; |
|
222 | - $controllerNamespace = $moduleNamespace . '\\' . 'Http\\Controllers'; |
|
223 | - $modelNameSpace = $moduleNamespace . '\\' . 'Entities\\' . $moduleName; |
|
221 | + $moduleName = explode('\\', $moduleNamespace)[ 1 ]; |
|
222 | + $controllerNamespace = $moduleNamespace.'\\'.'Http\\Controllers'; |
|
223 | + $modelNameSpace = $moduleNamespace.'\\'.'Entities\\'.$moduleName; |
|
224 | 224 | |
225 | 225 | return [ |
226 | 226 | 'path' => $path, |
@@ -240,8 +240,8 @@ discard block |
||
240 | 240 | private function buildPolicyArray($class, $namespace) |
241 | 241 | { |
242 | 242 | $moduleNamespace = $namespace; |
243 | - $moduleName = explode('\\', $moduleNamespace)[1]; |
|
244 | - $modelNameSpace = $moduleNamespace . '\\' . 'Entities\\' . $moduleName; |
|
243 | + $moduleName = explode('\\', $moduleNamespace)[ 1 ]; |
|
244 | + $modelNameSpace = $moduleNamespace.'\\'.'Entities\\'.$moduleName; |
|
245 | 245 | |
246 | 246 | return [ |
247 | 247 | 'class' => $class, |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function getCommands(): array |
280 | 280 | { |
281 | - return $this->loadBootstrapFromCache()['commands'] ?? []; |
|
281 | + return $this->loadBootstrapFromCache()[ 'commands' ] ?? [ ]; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function getRoutes(): array |
288 | 288 | { |
289 | - return $this->loadBootstrapFromCache()['routes'] ?? []; |
|
289 | + return $this->loadBootstrapFromCache()[ 'routes' ] ?? [ ]; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public function getConfigs(): array |
296 | 296 | { |
297 | - return $this->loadBootstrapFromCache()['configs'] ?? []; |
|
297 | + return $this->loadBootstrapFromCache()[ 'configs' ] ?? [ ]; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function getFactories(): array |
304 | 304 | { |
305 | - return $this->loadBootstrapFromCache()['factories'] ?? []; |
|
305 | + return $this->loadBootstrapFromCache()[ 'factories' ] ?? [ ]; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function getMigrations(): array |
312 | 312 | { |
313 | - return $this->loadBootstrapFromCache()['migrations'] ?? []; |
|
313 | + return $this->loadBootstrapFromCache()[ 'migrations' ] ?? [ ]; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | */ |
319 | 319 | public function getSeeders(): array |
320 | 320 | { |
321 | - return $this->loadBootstrapFromCache()['seeders'] ?? []; |
|
321 | + return $this->loadBootstrapFromCache()[ 'seeders' ] ?? [ ]; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function getModels(): array |
328 | 328 | { |
329 | - return $this->loadBootstrapFromCache()['models'] ?? []; |
|
329 | + return $this->loadBootstrapFromCache()[ 'models' ] ?? [ ]; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -334,6 +334,6 @@ discard block |
||
334 | 334 | */ |
335 | 335 | public function getPolicies(): array |
336 | 336 | { |
337 | - return $this->loadBootstrapFromCache()['policies'] ?? []; |
|
337 | + return $this->loadBootstrapFromCache()[ 'policies' ] ?? [ ]; |
|
338 | 338 | } |
339 | 339 | } |