/** * Returns whether is valid user name. * * @return bool True, if is valid user name. * @throws InvalidUserNameException */ public function isValidUserName() { if ((bool) preg_match('#^[a-z0-9]{4,128}$#', $this->request->getUserName())) { return true; } throw new InvalidUserNameException(); }