original_string: public static function add($password, $user = null)
      {
          if (static::isUsed($password, $user) && !$user->allowUsedPassword) {
              throw new InvalidParamException('Password existed.');
          }
          if (static::judgePasswordHash($password)) {
              $passwordHistory = $user->create(static::class);
              $passwordHistory->{$passwordHistory->passwordHashAttribute} = $password;
          } else {
              $passwordHistory = $user->create(static::class, ['password' => $password]);
          }
          /* @var $passwordHistory static */
          return $passwordHistory->save();
      }
code: public static function add($password, $user = null)
      {
          if (static::isUsed($password, $user) && !$user->allowUsedPassword) {
              throw new InvalidParamException('Password existed.');
          }
          if (static::judgePasswordHash($password)) {
              $passwordHistory = $user->create(static::class);
              $passwordHistory->{$passwordHistory->passwordHashAttribute} = $password;
          } else {
              $passwordHistory = $user->create(static::class, ['password' => $password]);
          }
          /* @var $passwordHistory static */
          return $passwordHistory->save();
      }
code_tokens: public static function add ( $ password , $ user = null ) { if ( static :: isUsed ( $ password , $ user ) && ! $ user -> allowUsedPassword ) { throw new InvalidParamException ( 'Password existed.' ) ; } if ( static :: judgePasswordHash ( $ password ) ) { $ passwordHistory = $ user -> create ( static :: class ) ; $ passwordHistory -> { $ passwordHistory -> passwordHashAttribute } = $ password ; } else { $ passwordHistory = $ user -> create ( static :: class , [ 'password' => $ password ] ) ; } /* @var $passwordHistory static */ return $ passwordHistory -> save ( ) ; }
docstring: Add password to history.
  
  @param string $password Password or Password Hash.
  @param User $user
  @return boolean
  @throws InvalidParamException throw if password existed.
docstring_tokens: Add password to history .