original_string: public function register()
      {
          if ($this->getIsNewRecord() == false) {
              throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
          }
  
          $module = UsersModule::module();
  
          if (empty($this->password) === true) {
              $this->password = PasswordHelper::generate($module->generatedPasswordLength);
          }
  
          if ($module->emailConfirmationNeeded === false) {
              $this->is_active = true;
          }
  
          $event = new RegistrationEvent();
          $this->trigger(self::EVENT_BEFORE_REGISTER, $event);
  
          if ($event->isValid === false) {
              return false;
          }
  
          if (!$this->save()) {
              return false;
          }
  
          $this->trigger(self::EVENT_AFTER_REGISTER, $event);
          return $this;
      }
code: public function register()
      {
          if ($this->getIsNewRecord() == false) {
              throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
          }
  
          $module = UsersModule::module();
  
          if (empty($this->password) === true) {
              $this->password = PasswordHelper::generate($module->generatedPasswordLength);
          }
  
          if ($module->emailConfirmationNeeded === false) {
              $this->is_active = true;
          }
  
          $event = new RegistrationEvent();
          $this->trigger(self::EVENT_BEFORE_REGISTER, $event);
  
          if ($event->isValid === false) {
              return false;
          }
  
          if (!$this->save()) {
              return false;
          }
  
          $this->trigger(self::EVENT_AFTER_REGISTER, $event);
          return $this;
      }
code_tokens: public function register ( ) { if ( $ this -> getIsNewRecord ( ) == false ) { throw new \ RuntimeException ( 'Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user' ) ; } $ module = UsersModule :: module ( ) ; if ( empty ( $ this -> password ) === true ) { $ this -> password = PasswordHelper :: generate ( $ module -> generatedPasswordLength ) ; } if ( $ module -> emailConfirmationNeeded === false ) { $ this -> is_active = true ; } $ event = new RegistrationEvent ( ) ; $ this -> trigger ( self :: EVENT_BEFORE_REGISTER , $ event ) ; if ( $ event -> isValid === false ) { return false ; } if ( ! $ this -> save ( ) ) { return false ; } $ this -> trigger ( self :: EVENT_AFTER_REGISTER , $ event ) ; return $ this ; }
docstring: This method is used to register new user account.
  
  @return bool|User
docstring_tokens: This method is used to register new user account .