Passed
Push — bugfix/relatives_not_saving ( 6485fa...f1e1c5 )
by Tristan
13:39
created

SessionTokenStorage   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 17
dl 0
loc 40
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A refreshKey() 0 2 1
A forgetAccess() 0 3 1
A forgetRefresh() 0 3 1
A saveRefresh() 0 4 1
A fetchRefresh() 0 3 1
A saveAccess() 0 4 1
A fetchAccess() 0 3 1
A accessKey() 0 2 1
1
<?php
2
3
namespace App\Services\Auth;
4
5
use App\Services\Auth\Contracts\TokenStorage;
6
7
class SessionTokenStorage implements TokenStorage {
8
9
    public function fetchRefresh(string $iss, string $sub) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::fetchRefresh() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function fetchRefresh()
Loading history...
10
        $key = $this->refreshKey($iss, $sub);
11
        return session($key);
0 ignored issues
show
Bug Best Practice introduced by
The expression return session($key) also could return the type Illuminate\Session\Sessi...lluminate\Session\Store which is incompatible with the return type mandated by App\Services\Auth\Contra...Storage::fetchRefresh() of null|string.
Loading history...
12
    }
13
14
    public function saveRefresh(string $iss, string $sub, string $refreshToken) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::saveRefresh() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function saveRefresh()
Loading history...
15
        $key = $this->refreshKey($iss, $sub);
16
        session([$key => $refreshToken]);
17
        return true;
18
    }
19
20
    protected function refreshKey(string $iss, string $sub) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::refreshKey() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function refreshKey()
Loading history...
21
        return $key = implode('.', ['refreshToken', $iss, $sub]);
0 ignored issues
show
Unused Code introduced by
The assignment to $key is dead and can be removed.
Loading history...
22
    }
23
24
    public function fetchAccess(string $iss, string $sub) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::fetchAccess() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function fetchAccess()
Loading history...
25
        $key = $this->accessKey($iss, $sub);
26
        return session($key);
0 ignored issues
show
Bug Best Practice introduced by
The expression return session($key) also could return the type Illuminate\Session\Sessi...lluminate\Session\Store which is incompatible with the return type mandated by App\Services\Auth\Contra...nStorage::fetchAccess() of null|string.
Loading history...
27
    }
28
29
    public function saveAccess(string $iss, string $sub, string $accessToken) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::saveAccess() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function saveAccess()
Loading history...
30
        $key = $this->accessKey($iss, $sub);
31
        session([$key => $accessToken]);
32
        return true;
33
    }
34
35
    protected function accessKey(string $iss, string $sub) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::accessKey() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function accessKey()
Loading history...
36
        return $key = implode('.', ['accessToken', $iss, $sub]);
0 ignored issues
show
Unused Code introduced by
The assignment to $key is dead and can be removed.
Loading history...
37
    }
38
39
    public function forgetAccess(string $iss, string $sub) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::forgetAccess() does not have void return type hint.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function forgetAccess()
Loading history...
40
        $key = $this->accessKey($iss, $sub);
41
        session()->forget($key);
42
    }
43
44
    public function forgetRefresh(string $iss, string $sub) {
1 ignored issue
show
introduced by
Method \App\Services\Auth\SessionTokenStorage::forgetRefresh() does not have void return type hint.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function forgetRefresh()
Loading history...
45
        $key = $this->refreshKey($iss, $sub);
46
        session()->forget($key);
47
    }
48
49
}
50