Conditions | 5 |
Paths | 6 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
39 | { |
||
40 | if (!$this->isValidUsername($username)) { |
||
41 | return null; |
||
42 | } |
||
43 | |||
44 | /** @var \Minepic\Models\Account $account */ |
||
45 | $account = $this->accountRepository->findLastUpdatedByUsername($username); |
||
46 | if ($account !== null) { |
||
47 | return $account->uuid; |
||
48 | } |
||
49 | |||
50 | if (!UserNotFoundCache::has($username)) { |
||
51 | try { |
||
52 | $mojangAccount = $this->mojangClient->sendUsernameInfoRequest($username); |
||
53 | |||
54 | return $mojangAccount->getUuid(); |
||
55 | } catch (\Throwable $exception) { |
||
56 | UserNotFoundCache::add($username); |
||
57 | } |
||
58 | } |
||
59 | |||
60 | return null; |
||
61 | } |
||
62 | |||
73 |