| Conditions | 5 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function resolve(string $username): ?string |
||
| 24 | { |
||
| 25 | if (!$this->isValidUsername($username)) { |
||
| 26 | return null; |
||
| 27 | } |
||
| 28 | |||
| 29 | $account = $this->accountRepository->findLastUpdatedByUsername($username); |
||
| 30 | if ($account !== null) { |
||
| 31 | return $account->uuid; |
||
| 32 | } |
||
| 33 | |||
| 34 | if (!UserNotFoundCache::has($username)) { |
||
| 35 | try { |
||
| 36 | $mojangAccount = $this->mojangClient->sendUsernameInfoRequest($username); |
||
| 37 | |||
| 38 | return $mojangAccount->getUuid(); |
||
| 39 | } catch (\Throwable $exception) { |
||
| 40 | UserNotFoundCache::add($username); |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | return null; |
||
| 45 | } |
||
| 52 |