<commit_before><?php


namespace PhrestSDK\Request;

/**
 * RequestOptions will handle any additional options that are sent through
 * i.e. expand, fields etc.
 *
 * todo this could be automated into the request objects based on annotations
 */
class RequestOptions
{

  private $searchTerm;
  // todo phase out
  private $parameters;

  private $postParams = [];
  private $getParams = [];

  /**
   * Use addGetParam/addPostParam accordingly
   *
   * @param      $param
   * @param bool $value
   *
   * @return $this
   * @throws \Exception
   * @deprecated
   */
  public function addParameter($param, $value = true)
  {
    if(!is_scalar($param))
    {
      throw new \Exception("Parameter filter must be scalar");
    }

    if(!isset($this->parameters))
    {
      $this->parameters = [];
    }

    return $this->addGetParam($param, $value);
  }

  /**
   * Add a GET parameter
   *
   * @param      $param
   * @param bool $value
   *
   * @return $this
   * @throws \Exception
   */
  public function addGetParam($param, $value = true)
  {
    // Validate
    if(!is_scalar($param))
    {
      throw new \Exception("Param name must be scalar");
    }

    // Filter
    if(is_string($value))
    {
      $value = trim($value);
    }

    // Set
    $this->getParams[trim($param)] = $value;

    return $this;
  }

  /**
   * Add a POST parameter
   *
   * @param      $param
   * @param bool $value
   *
   * @return $this
   * @throws \Exception
   */
  public function addPostParam($param, $value = true)
  {
    // Validate
    if(!is_scalar($param))
    {
      throw new \Exception("Param name must be scalar");
    }

    // Filter
    if(is_string($value))
    {
      $value = trim($value);
    }

    // Set
    $this->postParams[trim($param)] = $value;

    return $this;
  }


  /**
   * Set a search term for the request
   *
   * @param $searchTerm
   *
   * @return $this
   * @throws \Exception
   */
  public function setSearchTerm($searchTerm)
  {
    if(!is_scalar($searchTerm))
    {
      throw new \Exception("Search term must be a string");
    }

    $this->searchTerm = trim($searchTerm);

    return $this;
  }

  /**
   * Unset search term
   *
   * @return $this
   */
  public function unsetSearchTerm()<commit_msg>Added setter for multiple params<commit_after><?php


namespace PhrestSDK\Request;

/**
 * RequestOptions will handle any additional options that are sent through
 * i.e. expand, fields etc.
 *
 * todo this could be automated into the request objects based on annotations
 */
class RequestOptions
{

  private $searchTerm;
  // todo phase out
  private $parameters;

  private $postParams = [];
  private $getParams = [];

  /**
   * Use addGetParam/addPostParam accordingly
   *
   * @param      $param
   * @param bool $value
   *
   * @return $this
   * @throws \Exception
   * @deprecated
   */
  public function addParameter($param, $value = true)
  {
    if(!is_scalar($param))
    {
      throw new \Exception("Parameter filter must be scalar");
    }

    if(!isset($this->parameters))
    {
      $this->parameters = [];
    }

    return $this->addGetParam($param, $value);
  }

  /**
   * Add a GET parameter
   *
   * @param      $param
   * @param bool $value
   *
   * @return $this
   * @throws \Exception
   */
  public function addGetParam($param, $value = true)
  {
    // Validate
    if(!is_scalar($param))
    {
      throw new \Exception("Param name must be scalar");
    }

    // Filter
    if(is_string($value))
    {
      $value = trim($value);
    }

    // Set
    $this->getParams[trim($param)] = $value;

    return $this;
  }

  /**
   * Add a POST parameter
   *
   * @param      $param
   * @param bool $value
   *
   * @return $this
   * @throws \Exception
   */
  public function addPostParam($param, $value = true)
  {
    // Validate
    if(!is_scalar($param))
    {
      throw new \Exception("Param name must be scalar");
    }

    // Filter
    if(is_string($value))
    {
      $value = trim($value);
    }

    // Set
    $this->postParams[trim($param)] = $value;

    return $this;
  }

  public function addPostParams($params = [])
  {
    foreach($params as $k => $v)
    {
      $this->addPostParam($k, $v);
    }

    return $this;
  }


  /**
   * Set a search term for the request
   *
   * @param $searchTerm
   *
   * @return $this
   * @throws \Exception
   */
  public function setSearchTerm($searchTerm)
  {
    if(!is_scalar($searchTerm))
    {
      throw new \Exception("Search term must be a string");
    }

    $this->searchTerm = trim($searchTerm);

    return $this;
  }

  /**
   * Unset search term
   *
   * @return $this
   */
  public function unsetSearchTerm()
{'fraction_non_alphanumeric': 0.13996159590356305, 'fraction_numerical': 0.0, 'mean_word_length': 2.269177126917713, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3927061', 'n_tokens_mistral': 1526, 'n_tokens_neox': 1489, 'n_words': 378}