| Total Complexity | 7 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class TokenRepository implements TokenRepositoryInterface |
||
| 10 | { |
||
| 11 | 6 | public function create(array $tokenAttrs): Model |
|
| 12 | { |
||
| 13 | 6 | $tokenAttrs['token_type'] = 'Bearer'; |
|
| 14 | |||
| 15 | 6 | if (isset($tokenAttrs['expires_in'])) { |
|
| 16 | 6 | $tokenAttrs['expires_at'] = Carbon::now()->addSeconds($tokenAttrs['expires_in']); |
|
| 17 | } |
||
| 18 | |||
| 19 | 6 | return Token::create($tokenAttrs); |
|
|
|
|||
| 20 | } |
||
| 21 | |||
| 22 | 1 | public function retrieveAll() |
|
| 25 | } |
||
| 26 | |||
| 27 | 8 | public function retrieve(?string $accessToken = null): ?Model |
|
| 28 | { |
||
| 29 | 8 | if ($accessToken) { |
|
| 30 | 1 | return Token::where('access_token', $accessToken)->first(); |
|
| 31 | } |
||
| 32 | |||
| 33 | 7 | return Token::latest('created_at')->first(); |
|
| 34 | } |
||
| 35 | |||
| 36 | 1 | public function update(string $accessToken, array $tokenAttrs): Model |
|
| 37 | { |
||
| 38 | 1 | $token = Token::where('access_token', $accessToken)->firstOrFail(); |
|
| 39 | |||
| 40 | 1 | $token->update($tokenAttrs); |
|
| 41 | |||
| 42 | 1 | return $token->fresh(); |
|
| 43 | } |
||
| 44 | |||
| 45 | 2 | public function delete(string $accessToken): void |
|
| 48 | } |
||
| 49 | } |
||
| 50 |