public function usernameExists($userName)
    {
        $existing = $this->em->getRepository(User::class)->findOneBy(
            [
                'username' => $userName,
            ]
        );

        return (bool) $existing;
    }
public function usernameExists($userName)
    {
        $existing = $this->em->getRepository(User::class)->findOneBy(
            [
                'username' => $userName,
            ]
        );

        return (bool) $existing;
    }
public function usernameExists ( $ userName ) { $ existing = $ this -> em -> getRepository ( User :: class ) -> findOneBy ( [ 'username' => $ userName , ] ) ; return ( bool ) $ existing ; }
Check if a username is already in use

@param string $userName
@return bool
Check if a username is already in use