Finds user by username

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

        return null;
    }
1193865
public static function find($id)
    {
        $item = UserRBACHelper::getAuthManager()->getRule($id);
        if ($item !== null) {
            return new static($item);
        }

        return null;
    }
1259733
public function deleteUser($username)
    {
        $stmt = $this
            ->conn
            ->prepare(sprintf("DELETE * FROM %s WHERE user_name = :name", $this->table))
            ->execute(['name' => $username]);
        return $stmt->rowCount();
    }
778066
public static function findByUsername($username, $checkStatus = true)
    {
        return static::findOne(
            $checkStatus ?
                ['username' => $username, 'status' => self::STATUS_ACTIVE] :
                ['username' => $username]
        );
    }
413416
public static function isExistByUsername( $username ) {

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

		return isset( $user );
	}
152303
private function getUser($username)
    {
        if (!isset($this->users[strtolower($username)])) {
            $ex = new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
            $ex->setUsername($username);

            throw $ex;
        }

        return $this->users[strtolower($username)];
    }
394769
public function loadUserByUsername($username): User
    {
        foreach ($this->userRepositoryCollection->all() as $repository) {
            $user = $repository->findByUsername($username);

            if ($user instanceof User) {
                return $user;
            }
        }

        throw new UsernameNotFoundException(
            sprintf('Username "%s" does not exist.', $username)
        );
    }
406508
public static function findByUsernameOrEmail($username, $checkStatus = true)
    {
        $query = static::find();
        $query->where(['or', ['username' => $username], ['email' => $username]]);
        if ($checkStatus) {
            $query->andWhere(['status' => self::STATUS_ACTIVE]);
        }
        return $query->limit(1)->one();
    }
1277269
public function find($username, array $data = [])
    {
        $response = $this->request->get(sprintf("users/%s", $username), $data);
        return new User($this->master, $response);
    }
528430
public function findByName($playerName)
    {
        return $this->first(function (Player $player) use ($playerName) {
            return $player->name() === $playerName;
        });
    }
313735
public function find($username)
    {
        $response = $this->search($username);
        foreach ($response->get() as $user) {
            if ($username === $user['username']) {
                return $this->get($user['id']);
            }
        }
        return null;
    }
923135
public function find($username)
    {
        $column = 'username';
        if (is_numeric($username)) {
            $column = 'id';
        } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) {
            $column = 'email';
        } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) {
            $column = 'msisdn';
        }

        if ($user = models('users')->findWhere([$column => $username], 1)) {
            return $user;
        }

        return false;
    }
484879
public function loadUserByUsername($username)
    {
        $qb = $this->getEntityManager()->createQueryBuilder();

        return $qb
            ->select('u')
            ->from('CiscajaUhsaUserBundle:User', 'u')
            ->where(
                $qb->expr()->orX(
                    $qb->expr()->eq('u.username', ':username'),
                    $qb->expr()->eq('u.email', ':username')
                )
            )
            ->setParameters(array(
                'username' => $username
            ))
            ->getQuery()
            ->getOneOrNullResult();
    }
867572
public function setUsername($username){
        if(!$this->setModified('username', $username)->isModified()){
            return $this;
        }
        $this->username = $username;

        return $this;
    }
458525
public function loadUserByUsername($username)
    {
        if (!($username && $this->configSource->has('auth-password/' . $username))) {
            throw new UsernameNotFoundException();
        }

        $userData = $this->configSource->get('auth-password/' . $username);

        return new UserInformation(array_merge($userData, ['username' => $username]));
    }
154306
protected function getUserEntity($userName)
    {
        if (!$userEntity = $this->getRepositoryUsers()->getUser($userName)) {
            $this->flashLogger->error(Trans::__('general.phrase.error-user-name-password-incorrect'));

            return null;
        }

        if (!$userEntity->getEnabled()) {
            $this->systemLogger->alert("Attempt to login with disabled account by '$userName'", ['event' => 'security']);
            $this->flashLogger->error(Trans::__('general.phrase.login-account-disabled'));

            return null;
        }

        return $userEntity;
    }
423797
public function getUser($username)
    {
        $resellers = $this->getUsers();
        return isset($resellers[$username]) ? $resellers[$username] : null;
    }