Determine the amount of attempts remaining for a username

@param $username
@return int
17940
public function remainingAttempts($username)
    {
        $config = $this->config->get('concrete.user.deactivation.authentication_failure');

        $allowed = (int) array_get($config, 'amount', 0);
        $duration = (int) array_get($config, 'duration', 0);
        $after = Carbon::now('UTC')->subSeconds($duration);

        $user = $this->resolveUser($username);
        if (!$user) {
            return $allowed;
        }

        /** @var \Concrete\Core\Entity\User\LoginAttemptRepository $repository */
        $repository = $this->entityManager->getRepository(LoginAttempt::class);
        $attempts = $repository->after($after, $user, true);

        return max(0, $allowed - $attempts);
    }
862819
public function get($username) {


        if(is_numeric($username)) {
            $key = 'id';
        }
        else {
            $key = 'username';
        }

        $query = sprintf(self::SELECT_ALL,
            $this->params['table'],
            $this->params[$key],
            $this->pdo->quote($username));

        $stmt = $this->pdo->query($query);

		if(!$stmt) {
			$error = $this->pdo->errorInfo();
			
			throw new \Exception($error[2]);
		}
		
        if($user = $stmt->fetch(PDO::FETCH_ASSOC)) {
            return $user;
        }
        else {
            throw new UserException('User not found', 404);
        }
    }
1326768
public static function user($username)
    {
        $username = urlencode($username);

        return self::get(self::BASE_URL . '/json.php?username=' . $username);
    }
1176263
public function validateUserName($userName)
    {
        if (empty($userName)) {
            $this->addError('userName', 'User name cannot be empty');
            return false;
        }

        if (!is_string($userName)) {
            $this->addError('userName', 'User name must be a string');
            return false;
        }

        if (mb_strlen($userName, 'UTF-8') > 255) {
            $this->addError('userName', 'User name length has to be less or equal to 255');
            return false;
        }


        return true;
    }
180880
public function getSingleUser(string $username): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/users/:username', $username));
    }
53261
public function exists($username)
    {
        $response = $this->send(sprintf(
            'check_username/?api_token=%s&username=%s',
            $this->apiToken,
            strtoupper($username)
        ));
        $content = json_decode($response->getBody());

        return (boolean) $content->exists;
    }
1263992
function getAccountInfoByUsername($username)
    {
        $response = $this->call( new Command\AccountInfo($username, Command\AccountInfo::TYPE_USERNAME) );
        if ( $ex = $response->hasException() )
            throw $ex;

        $r = $response->expected();
        $r = ($r instanceof iDataEntity) ? $r->get('result') : $r;
        return $r;
    }
289319
public function userCheckName($username)
    {
        $params =  compact('username');
        $validator = Validator::make($params, [
            'username' => 'uc_username'
        ]);
        if ($validator->fails())
            throw new UcException('用户名不合法', -1);


        $response = $this->apiPost('user', 'check_username', $params);
        if (0 > $response) {
            switch ($response) {
                case '-1':
                    throw new UcException('用户名不合法', -1);
                    break;
                case '-2':
                    throw new UcException('包含要允许注册的词语', -2);
                    break;
                case '-3':
                    throw new UcException('用户名已经存在', -3);
                    break;
                default:
                    throw new UcException('未知错误', $response);
                    break;
            }
        }
        return true;
    }
635524
public function getAnnotationsCount($annotationName) {
		if (isset($this->annotationsArrayAsString[$annotationName]))
			return count($this->annotationsArrayAsString[$annotationName]);
		else
			return 0;
	}
413416
public static function isExistByUsername( $username ) {

		$user = self::find()->where( 'username=:username', [ ':username' => $username ] )->one();

		return isset( $user );
	}
45563
public function count($queueName = '')
    {
        if (isset($this->queues[$queueName])) {
            return count($this->queues[$queueName]);
        }
        return 0;
    }
340504
public function getIdFromUsername($username)
    {
        $id = $this->load('uname2uid', $username);

        return ($id === 0) ? null : (int) $id;
    }
766810
public static function findByUsername($username)
    {
        foreach (self::$users as $user) {
            if (strcasecmp($user['username'], $username) === 0) {
                return new static($user);
            }
        }

        return null;
    }
826751
public function existsByUsername ($username)
    {
        $entity = $this->er->findOneBy(array('username' => $username));

        if (NULL == $entity) {
            return false;
        } else {
            return true;
        }
    }
776285
public function validateUsername($username)
    {
        $person = $this->getService('repos:people.person')->find(array('username' => $username));

        if ($person) {
            $this->setMessage('Username is already in use');
            return false;
        }

        return true;
    }
692728
public static function getUser($username = null)
	{
		if ( is_null( $username ) ) $username = self::getCurrentUsername();

		if ( self::userExists( $username ) ) {
			return self::$auth['users'][ $username ];
		}

		return null;
	}
778283
public function checkAccountStatus($username)
    {
        $statusCodes = [
            0 => 'UNVERIFIED',
            1 => 'VERIFIED',
            2 => 'CERTIFIED',
            3 => 'CERTIFIED_PREMIUM',
        ];

        if (false !== ($response = $this->request('api/CekStatus.php', ['user' => $username]))) {
            return $statusCodes[ $response[ 'StatusUser' ] ];
        }

        return false;
    }