| Conditions | 4 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 38 | public function resolve(string $username): ?string |
||
| 39 | { |
||
| 40 | /** @var \App\Models\Account $account */ |
||
| 41 | $account = $this->accountRepository->findLastUpdatedByUsername($username); |
||
| 42 | if ($account) { |
||
|
|
|||
| 43 | return $account->uuid; |
||
| 44 | } |
||
| 45 | |||
| 46 | if (UserNotFoundCache::has($username)) { |
||
| 47 | Log::debug('User not found cache hit'); |
||
| 48 | |||
| 49 | return env('DEFAULT_UUID'); |
||
| 50 | } |
||
| 51 | |||
| 52 | try { |
||
| 53 | $mojangAccount = $this->mojangClient->sendUsernameInfoRequest($username); |
||
| 54 | |||
| 55 | return $mojangAccount->getUuid(); |
||
| 56 | } catch (\Throwable $exception) { |
||
| 57 | UserNotFoundCache::add($username); |
||
| 58 | |||
| 59 | return env('DEFAULT_UUID'); |
||
| 60 | } |
||
| 63 |