src/Faker/Internet.php
public static function userName($name = null)
    {
        if ($name !== null) {
            $email = preg_split('/\W+/', $name);
            shuffle($email);
            $email = implode(self::separator(), $email);
        } else {
            $email = sprintf(
                self::pickOne(array(
                    '%s',
                    '%s%s%s'
                )),
                Name::firstName(),
                self::separator(),
                Name::lastName()
            );
        }

        return strtolower(preg_replace('/\W/', '', $email));
    }
public static function userName($name = null)
    {
        if ($name !== null) {
            $email = preg_split('/\W+/', $name);
            shuffle($email);
            $email = implode(self::separator(), $email);
        } else {
            $email = sprintf(
                self::pickOne(array(
                    '%s',
                    '%s%s%s'
                )),
                Name::firstName(),
                self::separator(),
                Name::lastName()
            );
        }

        return strtolower(preg_replace('/\W/', '', $email));
    }
public static function userName ( $ name = null ) { if ( $ name !== null ) { $ email = preg_split ( '/\W+/' , $ name ) ; shuffle ( $ email ) ; $ email = implode ( self :: separator ( ) , $ email ) ; } else { $ email = sprintf ( self :: pickOne ( array ( '%s' , '%s%s%s' ) ) , Name :: firstName ( ) , self :: separator ( ) , Name :: lastName ( ) ) ; } return strtolower ( preg_replace ( '/\W/' , '' , $ email ) ) ; }
Generate a random username.

Optionally, supply a user's name, from which the username will be generated.

@access public
@static
@param string $name (default: null)
@return string Username
Generate a random username .