@@ -13,6 +13,6 @@ |
||
13 | 13 | | |
14 | 14 | */ |
15 | 15 | |
16 | -Route::get('/test', function (Request $request) { |
|
16 | +Route::get('/test', function(Request $request) { |
|
17 | 17 | return response()->json('welcome to the api'); |
18 | 18 | }); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | $this->resolver->setDefaultConnection($this->getDatabase()); |
36 | 36 | |
37 | - Model::unguarded(function () { |
|
37 | + Model::unguarded(function() { |
|
38 | 38 | foreach ($this->getSeeders() as $seeder) { |
39 | 39 | $seeder = $this->laravel->make($seeder); |
40 | 40 | $seeder->__invoke(); |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | { |
49 | 49 | $this->service = $this->laravel->make(BootstrapRegistrarService::class); |
50 | 50 | |
51 | - return $this->service->getSeeders() ?? []; |
|
51 | + return $this->service->getSeeders() ?? [ ]; |
|
52 | 52 | } |
53 | 53 | } |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | use Modules\User\Entities\User; |
4 | 4 | |
5 | -$factory->define(User::class, function (Faker\Generator $faker) { |
|
5 | +$factory->define(User::class, function(Faker\Generator $faker) { |
|
6 | 6 | return [ |
7 | 7 | 'auth0_id' => null, |
8 | 8 | 'name' => $faker->name, |
@@ -14,6 +14,6 @@ |
||
14 | 14 | |
15 | 15 | protected $collection = 'users'; |
16 | 16 | |
17 | - protected $guarded = []; |
|
17 | + protected $guarded = [ ]; |
|
18 | 18 | |
19 | 19 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | | This is used to verify the decoded tokens when using RS256 |
60 | 60 | | |
61 | 61 | */ |
62 | - 'authorized_issuers' => [env('AUTH0_DOMAIN')], |
|
62 | + 'authorized_issuers' => [ env('AUTH0_DOMAIN') ], |
|
63 | 63 | |
64 | 64 | /* |
65 | 65 | |-------------------------------------------------------------------------- |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | | Token decoding algorithms supported by your API |
86 | 86 | | |
87 | 87 | */ |
88 | - 'supported_algs' => ['RS256'], |
|
88 | + 'supported_algs' => [ 'RS256' ], |
|
89 | 89 | |
90 | 90 | /* |
91 | 91 | |-------------------------------------------------------------------------- |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function getUserByUserInfo($userInfo) |
44 | 44 | { |
45 | - return $this->upsertUser($userInfo['profile']); |
|
45 | + return $this->upsertUser($userInfo[ 'profile' ]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | protected function upsertUser($profile) |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | throw new Exception('Missing token information: Auth0 user id is not set'); |
52 | 52 | } |
53 | 53 | $identifier = explode('|', $profile->user_id); |
54 | - $identityProvider = $identifier[0]; |
|
55 | - $id = $identifier[1]; |
|
54 | + $identityProvider = $identifier[ 0 ]; |
|
55 | + $id = $identifier[ 1 ]; |
|
56 | 56 | |
57 | 57 | $user = $this->service->find($id); |
58 | 58 |
@@ -16,7 +16,7 @@ |
||
16 | 16 | { |
17 | 17 | public function find($id): ?User |
18 | 18 | { |
19 | - return Cache::remember($this->getCacheName($id), $this->getCacheTime(), function () use ($id) { |
|
19 | + return Cache::remember($this->getCacheName($id), $this->getCacheTime(), function() use ($id) { |
|
20 | 20 | return User::find($id); |
21 | 21 | }); |
22 | 22 | } |
@@ -39,8 +39,9 @@ |
||
39 | 39 | public function delete($id): bool |
40 | 40 | { |
41 | 41 | $deleted = User::destroy($id); |
42 | - if ($deleted) |
|
43 | - Cache::forget($this->getCacheName($id)); |
|
42 | + if ($deleted) { |
|
43 | + Cache::forget($this->getCacheName($id)); |
|
44 | + } |
|
44 | 45 | return $deleted; |
45 | 46 | } |
46 | 47 |
@@ -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); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | private function storeInCache($data) |
42 | 42 | { |
43 | - file_put_contents($this->getCachePath(), '<?php return ' . var_export($data, true) . ';'); |
|
43 | + file_put_contents($this->getCachePath(), '<?php return '.var_export($data, true).';'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | public function readFromCache() |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | |
61 | 61 | private function getCachePath(): string |
62 | 62 | { |
63 | - return app()->bootstrapPath() . '/cache/' . $this->cacheFile; |
|
63 | + return app()->bootstrapPath().'/cache/'.$this->cacheFile; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | private function buildEmptyBootstrapArray() |
67 | 67 | { |
68 | - $bootstrapArray = []; |
|
68 | + $bootstrapArray = [ ]; |
|
69 | 69 | foreach ($this->moduleEntityDirectories as $key => $directory) { |
70 | - $bootstrapArray[$key] = []; |
|
70 | + $bootstrapArray[ $key ] = [ ]; |
|
71 | 71 | } |
72 | 72 | return $bootstrapArray; |
73 | 73 | } |
@@ -78,39 +78,39 @@ discard block |
||
78 | 78 | foreach (\Module::all() as $module) { |
79 | 79 | foreach ($this->moduleEntityDirectories as $key => $directory) { |
80 | 80 | $directory = ucfirst($directory); |
81 | - $directoryPath = $module->getPath() . '/' . $directory; |
|
82 | - $namespace = 'Modules' . '\\' . $module->getName(); |
|
81 | + $directoryPath = $module->getPath().'/'.$directory; |
|
82 | + $namespace = 'Modules'.'\\'.$module->getName(); |
|
83 | 83 | if (file_exists($directoryPath)) { |
84 | 84 | $files = scandir($directoryPath); |
85 | 85 | foreach ($files as $fileName) { |
86 | 86 | if ($this->hasPhpExtension($fileName)) { |
87 | 87 | $className = basename($fileName, '.php'); |
88 | - $class = $namespace . '\\' . str_replace('/', '\\', $directory) . '\\' . $className; |
|
88 | + $class = $namespace.'\\'.str_replace('/', '\\', $directory).'\\'.$className; |
|
89 | 89 | switch ($key) { |
90 | 90 | case 'commands': |
91 | 91 | try { |
92 | 92 | $command = new $class(); |
93 | 93 | if ($command instanceof Command) { |
94 | - $bootstrap[$key][] = $class; |
|
94 | + $bootstrap[ $key ][ ] = $class; |
|
95 | 95 | } |
96 | 96 | } catch (\Exception $e) { |
97 | 97 | break; |
98 | 98 | } |
99 | 99 | break; |
100 | 100 | case 'routes': |
101 | - $bootstrap[$key][] = $this->buildRouteArray($directoryPath . '/' . $fileName, $namespace); |
|
101 | + $bootstrap[ $key ][ ] = $this->buildRouteArray($directoryPath.'/'.$fileName, $namespace); |
|
102 | 102 | break; |
103 | 103 | case 'configs': |
104 | - $bootstrap[$key][] = $this->buildConfigArray($directoryPath . '/' . $fileName, $module->getName()); |
|
104 | + $bootstrap[ $key ][ ] = $this->buildConfigArray($directoryPath.'/'.$fileName, $module->getName()); |
|
105 | 105 | break; |
106 | 106 | case 'factories': |
107 | - $bootstrap[$key][] = $this->buildDirectoryPathArray($directoryPath); |
|
107 | + $bootstrap[ $key ][ ] = $this->buildDirectoryPathArray($directoryPath); |
|
108 | 108 | break; |
109 | 109 | case 'migrations': |
110 | - $bootstrap[$key][] = $this->buildDirectoryPathArray($directoryPath); |
|
110 | + $bootstrap[ $key ][ ] = $this->buildDirectoryPathArray($directoryPath); |
|
111 | 111 | break; |
112 | 112 | case 'seeders': |
113 | - $bootstrap[$key][] = $class; |
|
113 | + $bootstrap[ $key ][ ] = $class; |
|
114 | 114 | break; |
115 | 115 | default: |
116 | 116 | break; |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | |
127 | 127 | private function hasPhpExtension(string $fileName): bool |
128 | 128 | { |
129 | - return strlen($fileName) > 4 && '.php' === ($fileName[-4] . $fileName[-3] . $fileName[-2] . $fileName[-1]); |
|
129 | + return strlen($fileName) > 4 && '.php' === ($fileName[-4 ].$fileName[-3 ].$fileName[-2 ].$fileName[-1 ]); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | public function loadBootstrapFromCache() |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | $apiDomain = str_replace('http://', '', $apiDomain); |
148 | 148 | $apiDomain = str_replace('https://', '', $apiDomain); |
149 | 149 | $moduleNamespace = $namespace; |
150 | - $moduleName = explode('\\', $moduleNamespace)[1]; |
|
151 | - $controllerNamespace = $moduleNamespace . '\\' . 'Http\\Controllers'; |
|
152 | - $modelNameSpace = $moduleNamespace . '\\' . 'Entities\\' . $moduleName; |
|
150 | + $moduleName = explode('\\', $moduleNamespace)[ 1 ]; |
|
151 | + $controllerNamespace = $moduleNamespace.'\\'.'Http\\Controllers'; |
|
152 | + $modelNameSpace = $moduleNamespace.'\\'.'Entities\\'.$moduleName; |
|
153 | 153 | return [ |
154 | 154 | "path" => $path, |
155 | 155 | "namespace" => $namespace, |
@@ -177,31 +177,31 @@ discard block |
||
177 | 177 | |
178 | 178 | public function getCommands(): array |
179 | 179 | { |
180 | - return $this->loadBootstrapFromCache()['commands'] ?? []; |
|
180 | + return $this->loadBootstrapFromCache()[ 'commands' ] ?? [ ]; |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | public function getRoutes(): array |
184 | 184 | { |
185 | - return $this->loadBootstrapFromCache()['routes'] ?? []; |
|
185 | + return $this->loadBootstrapFromCache()[ 'routes' ] ?? [ ]; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | public function getConfigs(): array |
189 | 189 | { |
190 | - return $this->loadBootstrapFromCache()['configs'] ?? []; |
|
190 | + return $this->loadBootstrapFromCache()[ 'configs' ] ?? [ ]; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | public function getFactories(): array |
194 | 194 | { |
195 | - return $this->loadBootstrapFromCache()['factories'] ?? []; |
|
195 | + return $this->loadBootstrapFromCache()[ 'factories' ] ?? [ ]; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | public function getMigrations(): array |
199 | 199 | { |
200 | - return $this->loadBootstrapFromCache()['migrations'] ?? []; |
|
200 | + return $this->loadBootstrapFromCache()[ 'migrations' ] ?? [ ]; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | public function getSeeders(): array |
204 | 204 | { |
205 | - return $this->loadBootstrapFromCache()['seeders'] ?? []; |
|
205 | + return $this->loadBootstrapFromCache()[ 'seeders' ] ?? [ ]; |
|
206 | 206 | } |
207 | 207 | } |