for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Nord\Lumen\Search;
use Nord\Lumen\Search\Exceptions\InvalidArgument;
class Sort
{
const DIRECTION_ASCENDING = 'asc';
const DIRECTION_DESCENDING = 'desc';
/**
* @var string
*/
private $property;
private $direction;
* @var array
private $validDirections = [self::DIRECTION_ASCENDING, self::DIRECTION_DESCENDING];
* Sort constructor.
*
* @param string $property
* @param string $direction
public function __construct($property, $direction)
$this->setProperty($property);
$this->setDirection($direction);
}
* @return string
public function getProperty()
return $this->property;
public function getDirection()
return $this->direction;
private function setProperty($property)
$this->property = $property;
* @throws InvalidArgument
private function setDirection($direction)
if (!in_array($direction, $this->validDirections)) {
throw new InvalidArgument("Sort direction '$direction' is not supported.");
$this->direction = $direction;