getClient()->get($this->buildUsernameToUUIDRoute($username), $query); if ($response->getStatusCode() === 204) { throw new NoContentException('Username not found'); } if ($response->getStatusCode() !== 200) { throw new MojangApiException('Unexpected request result'); } $data = json_decode($response->getBody(), true); $responseObj = new UsernameToUUIDResponse(); $responseObj->id = $data['id']; $responseObj->name = $data['name']; $responseObj->legacy = isset($data['legacy']); $responseObj->demo = isset($data['demo']); return $responseObj; } /** * @return \GuzzleHttp\Client */ protected function getClient() { return Yii::$app->guzzle; } protected function buildUsernameToUUIDRoute($username) { return 'https://api.mojang.com/users/profiles/minecraft/' . $username; } }