You are here

class SearchRecordParameters in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/src/AuditLog/Params/SearchRecordParameters.php \Smartling\AuditLog\Params\SearchRecordParameters

Hierarchy

Expanded class hierarchy of SearchRecordParameters

3 files declare their use of SearchRecordParameters
AuditLogApi.php in vendor/smartling/api-sdk-php/src/AuditLog/AuditLogApi.php
AuditLogApiFunctionalTest.php in vendor/smartling/api-sdk-php/tests/functional/AuditLogApiFunctionalTest.php
AuditLogApiTest.php in vendor/smartling/api-sdk-php/tests/unit/AuditLogApiTest.php

File

vendor/smartling/api-sdk-php/src/AuditLog/Params/SearchRecordParameters.php, line 8

Namespace

Smartling\AuditLog\Params
View source
class SearchRecordParameters extends BaseParameters {
  const ORDER_DESC = 'desc';
  const ORDER_ASC = 'asc';
  public function __construct() {
    $this
      ->setOffset(0);
    $this
      ->setLimit(10);
    $this
      ->setSort("_seq_no", SearchRecordParameters::ORDER_DESC);
  }
  public function setSearchQuery($searchQuery) {
    $this
      ->set('q', (string) $searchQuery);
    return $this;
  }
  public function setOffset($offset) {
    if (!is_int($offset) || $offset < 0) {
      throw new InvalidArgumentException('Offset value must be grater or equal to zero.');
    }
    $this
      ->set('offset', $offset);
    return $this;
  }
  public function setLimit($limit) {
    if (!is_int($limit) || $limit < 1) {
      throw new InvalidArgumentException('Limit value must be grater or equal to one.');
    }
    $this
      ->set('limit', $limit);
    return $this;
  }
  public function setSort($field, $order) {
    $allowedSortOrders = [
      SearchRecordParameters::ORDER_DESC,
      SearchRecordParameters::ORDER_ASC,
    ];
    if (!in_array($order, $allowedSortOrders)) {
      throw new InvalidArgumentException('Allowed sort orders are: ' . implode(', ', $allowedSortOrders));
    }
    $this
      ->set('sort', "{$field}:{$order}");
    return $this;
  }

}

Members