You are here

public function SearchRecordParameters::setSort 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::setSort()
1 call to SearchRecordParameters::setSort()
SearchRecordParameters::__construct in vendor/smartling/api-sdk-php/src/AuditLog/Params/SearchRecordParameters.php

File

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

Class

SearchRecordParameters

Namespace

Smartling\AuditLog\Params

Code

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;
}