Check if a word is based on a username

@param   string  $word
@param   string  $username
@return  bool
435520
public static function isBasedOnUsername($word, $username)
	{
		$word     = self::normalize($word);
		$username = self::normalize($username);

		$words   = array();
		$words[] = $username;
		$words[] = strrev($username);

		foreach ($words as $w)
		{
			if (empty($w))
			{
				continue;
			}

			if (empty($word))
			{
				continue;
			}

			if (strpos($w, $word) !== false)
			{
				return true;
			}
		}

		return false;
	}
1175168
private function getStoredPassword($username)
    {
        // Get table object
        $db = $this->app->db->reset()->table($this->table);

        // Find user by username column
        $user = $db->select($this->passwordColumn)->limit(1)->where($this->usernameColumn, $username)->getOne();

        // Abort if the user or the password column do not exist
        if (!is_array($user) || !isset($user[$this->passwordColumn])) {
            return false;
        }

        // Return password column
        return $user[$this->passwordColumn];
    }
633053
public function getByUsername($username)
    {
        if (!is_string($username)) {
            return false;
        }

        $data = [
            'where' => [
                [
                    'column' => $this->tableAlias . '.username',
                    'value'  => $username,
                ],
            ],
        ];

        $user = $this->getAll(null, null, $data);

        return empty($user) ? false : $user[0];
    }
97894
public function validateUsernameOrEmail($username)
    {
        $username = trim($username);
        if (!strlen($username) || (!filter_var($username, FILTER_VALIDATE_EMAIL) && !$this->validateUsername($username))) {
            throw new \RuntimeException(
                'Please enter a valid email address or username.'
            );
        }

        return $username;
    }
951722
public function hasEnabledUsername()
    {
        if ($this->usernameClass === false || !is_string($this->usernameClass) || !class_exists($this->usernameClass)) {
            return false;
        }
        return true;
    }
744973
public function checkUserCredentials($username, $password)
	{
		// allow authentication via email, just like in the hub
		if (strpos($username, '@'))
		{
			$username = $this->getUsernameFromEmail($username);
		}

		// use hubzero password library to compare stored password with sent password
		$match = Password::passwordMatches($username, $password, true);

		// return if match was found
		return (bool) $match;
	}
700224
public function checkFollowingUser(string $username): bool
    {
        $this->getApi()->request($this->getApi()->sprintf('/user/following/:username', $username));

        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
            return true;
        }

        return false;
    }
1338689
public function login(string $username, string $password)
    {
        $this->userInfo = $this->makeRequest('POST', 'login', compact('username', 'password'));

        if (!isset($this->userInfo['error']) && isset($this->userInfo['data']['id'])) {
            return true;
        }

        return false;
    }
32043
public function delete($username): bool
    {
        $user = $this->load($username);

        $exists = $user->exists();
        if ($exists) {
            $user->delete();
        }

        return $exists;
    }
1004967
public function username($username)
    {
        $app = Application::getFacadeApplication();
        $validator = $app->make('validator/user/name');
        foreach ($validator->getValidators() as $handle => $validator) {
            if ($handle !== 'unique_username') {
                if (!$validator->isValid($username)) {
                    return false;
                }
            }
        }

        return true;
    }
297052
public boolean hasUser(String userName) {
        boolean result = false;
        for (User item : getUsersList()) {
            if (item.getName().equals(userName)) {
                result = true;
            }
        }
        return result;
    }
1162425
protected function getUserByName(string $username)
    {
        $found_user = null;
        $users      = $this->getWordpressParameter('users');

        foreach ($users as $user) {
            if ($username === $user['username']) {
                $found_user = $user;
                break;
            }
        }

        if ($found_user === null) {
            throw new RuntimeException("[W801] User not found for name \"{$username}\"");
        }

        return $found_user;
    }
229494
public function setUsername($username)
    {
        if($username == $this->username){
            return true;
        }
        if ($this->usernameExists($username)) {
            return false;
        }

        if ($this->setUsernameStatement === null) {
            $this->setUsernameStatement = $this->connection->prepare("UPDATE User SET username = ? WHERE username = ?");
        }
        $wasLoggedIn = $this->isLoggedIn();

        $this->setUsernameStatement->execute(array($username, $this->username));
        $this->username = $username;

        if ($wasLoggedIn) {
            $this->updateLoginSession();
        }
        $this->notifyObservers(User::EVENT_USERNAME_UPDATE);
        return true;
    }
652669
public static function userExists($username)
	{
		if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );
		return ( isset( self::$auth['users'][ $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;
    }
344556
public function findByUsername($username)
    {
        $qb = $this->createQueryBuilder("u");
        $qb->where("(u.username = :username OR u.email = :email)")
            ->setParameter("username", $username)
            ->setParameter("email", $username);
        $qb->andWhere("u.status = :status")->setParameter("status", 1);
        $qb->setMaxResults(1);
        return $qb->getQuery()->getOneOrNullResult();
    }
197000
public function isPlural($word)
    {
        // Try the cache for an known inflection.
        $inflection = $this->getCachedSingular($word);

        if ($inflection !== false) {
            return true;
        }

        // Compute the inflection to cache the values, and compare.
        return $this->toPlural($this->toSingular($word)) == $word;
    }