original_string: public function addRating(int $type, int $itemId, int $rating): UserRatingsDataNoLinks
      {
          if (!in_array($type, self::$ratingTypes, true)) {
              throw new InvalidArgumentException(
                  'Invalid rating type, use one of these instead: ' . implode(self::$ratingTypes, ', ')
              );
          }
  
          try {
              $json = $this->client->performApiCallWithJsonResponse(
                  'put',
                  sprintf(
                      'user/ratings/%s/%d/%d',
                      $type,
                      (int) $itemId,
                      (int) $rating
                  ),
                  [
                      'http_errors' => true
                  ]
              );
          } catch (ClientException $e) {
              $message = $this->getApiErrorMessage($e->getResponse());
  
              if ($message !== '') {
                  throw CouldNotAddOrUpdateUserRatingException::reason($message);
              }
  
              throw CouldNotAddOrUpdateUserRatingException::reason($e->getMessage());
          }
  
          return ResponseHandler::create($json, ResponseHandler::METHOD_USER_RATINGS_ADD)->handle();
      }
code: public function addRating(int $type, int $itemId, int $rating): UserRatingsDataNoLinks
      {
          if (!in_array($type, self::$ratingTypes, true)) {
              throw new InvalidArgumentException(
                  'Invalid rating type, use one of these instead: ' . implode(self::$ratingTypes, ', ')
              );
          }
  
          try {
              $json = $this->client->performApiCallWithJsonResponse(
                  'put',
                  sprintf(
                      'user/ratings/%s/%d/%d',
                      $type,
                      (int) $itemId,
                      (int) $rating
                  ),
                  [
                      'http_errors' => true
                  ]
              );
          } catch (ClientException $e) {
              $message = $this->getApiErrorMessage($e->getResponse());
  
              if ($message !== '') {
                  throw CouldNotAddOrUpdateUserRatingException::reason($message);
              }
  
              throw CouldNotAddOrUpdateUserRatingException::reason($e->getMessage());
          }
  
          return ResponseHandler::create($json, ResponseHandler::METHOD_USER_RATINGS_ADD)->handle();
      }
code_tokens: public function addRating ( int $ type , int $ itemId , int $ rating ) : UserRatingsDataNoLinks { if ( ! in_array ( $ type , self :: $ ratingTypes , true ) ) { throw new InvalidArgumentException ( 'Invalid rating type, use one of these instead: ' . implode ( self :: $ ratingTypes , ', ' ) ) ; } try { $ json = $ this -> client -> performApiCallWithJsonResponse ( 'put' , sprintf ( 'user/ratings/%s/%d/%d' , $ type , ( int ) $ itemId , ( int ) $ rating ) , [ 'http_errors' => true ] ) ; } catch ( ClientException $ e ) { $ message = $ this -> getApiErrorMessage ( $ e -> getResponse ( ) ) ; if ( $ message !== '' ) { throw CouldNotAddOrUpdateUserRatingException :: reason ( $ message ) ; } throw CouldNotAddOrUpdateUserRatingException :: reason ( $ e -> getMessage ( ) ) ; } return ResponseHandler :: create ( $ json , ResponseHandler :: METHOD_USER_RATINGS_ADD ) -> handle ( ) ; }
docstring: Add user rating.
  
  @param int $type Use class constants UsersExtension::RATING_TYPE_*
  @param int $itemId
  @param int $rating Value between 1 and 10
  @return UserRatingsDataNoLinks
  @throws RequestFailedException
  @throws UnauthorizedException
  @throws InvalidArgumentException
  @throws InvalidJsonInResponseException
docstring_tokens: Add user rating .