| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 27 | public function handle($request, Closure $next) |
||
| 28 | { |
||
| 29 | $bearerToken = $request->bearerToken(); |
||
| 30 | |||
| 31 | if (is_null($bearerToken)) { |
||
| 32 | throw new HttpException(401, 'Bearer token not set', null, ['WWW-Authenticate' => 'Bearer']); |
||
| 33 | } |
||
| 34 | |||
| 35 | try { |
||
| 36 | $dedicatedServer = DedicatedServer::where('gdaemon_api_key', '=', $bearerToken)->firstOrFail(); |
||
| 37 | } catch (ModelNotFoundException $exception) { |
||
| 38 | throw new InvalidApiKeyException('Invalid api token'); |
||
| 39 | } |
||
| 40 | |||
| 41 | app()->instance(DedicatedServer::class, $dedicatedServer); |
||
| 42 | |||
| 43 | return $next($request); |
||
| 44 | } |
||
| 46 |