public function parse(array $data, ParsingDispatcher $parsingDispatcher)
{
if (!class_exists($this->valueObjectClass)) {
throw new Exceptions\Parser("Value object class <{$this->valueObjectClass}> is not defined");
}
if (!array_key_exists($this->dataKey, $data)) {
throw new Exceptions\Parser("The <{$this->dataKey}> sort clause doesn't exist in the input structure");
}
$direction = $data[$this->dataKey];
if (!in_array($direction, [Query::SORT_ASC, Query::SORT_DESC])) {
throw new Exceptions\Parser("Invalid direction format in <{$this->dataKey}> sort clause");
}
return new $this->valueObjectClass($direction);
}