AuthController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 18
ccs 0
cts 9
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getToken() 0 8 1
A __construct() 0 3 1
1
<?php
2
3
namespace Gameap\Http\Controllers\GdaemonAPI;
4
5
use Carbon\Carbon;
6
use Gameap\Models\DedicatedServer;
7
use Illuminate\Routing\Controller as BaseController;
8
use Illuminate\Support\Str;
9
10
class AuthController extends BaseController
11
{
12
    public function __construct()
13
    {
14
        $this->middleware('gdaemonApiAuth');
15
    }
16
17
    /**
18
     * @return \Illuminate\Http\JsonResponse
19
     */
20
    public function getToken(DedicatedServer $dedicatedServer)
21
    {
22
        $dedicatedServer->gdaemon_api_token = Str::Random(64);
23
        $dedicatedServer->update();
24
25
        return response()->json([
26
            'token'     => $dedicatedServer->gdaemon_api_token,
27
            'timestamp' => Carbon::now()->timestamp,
28
        ]);
29
    }
30
}
31