Exeu/Amazon-ECS-PHP-Library

The sort function

Opened this issue · 0 comments

/**
 * Setting the sort to a specified value.
 * Allows to sort results, only if the cattegory selected is not 'ALL'
 *
 * @param string $parameter
 *
 * @return AmazonECS
 * 
 * @autor alacret
 * 
 */
public function sort($parameter) {
    if(!isset($this -> requestConfig['category']) or $this -> requestConfig['category'] == null ){
        throw new InvalidArgumentException('A category must be set before adding the sort parameter');
    }
    if($this -> requestConfig['category'] == "All" ){
        throw new InvalidArgumentException('The sort is not supported for the "All" category');
    }
    if($parameter == null or $parameter == "" ){
        throw new InvalidArgumentException(sprintf('%s : invalid value for sort parameter',$parameter));
    }

    $this -> responseConfig['optionalParameters'] = array_merge($this -> responseConfig['optionalParameters'], array("Sort" => $parameter));

    return $this;
}