Conditions | 3 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 1 |
1 | <?php |
||
38 | public function parse(array $data, ParsingDispatcher $parsingDispatcher) |
||
39 | { |
||
40 | if (!array_key_exists($this->dataKey, $data)) { |
||
41 | throw new Exceptions\Parser("The <{$this->dataKey}> sort clause doesn't exist in the input structure"); |
||
42 | } |
||
43 | |||
44 | $direction = $data[$this->dataKey]; |
||
45 | |||
46 | if (!in_array($direction, [Query::SORT_ASC, Query::SORT_DESC])) { |
||
47 | throw new Exceptions\Parser("Invalid direction format in <{$this->dataKey}> sort clause"); |
||
48 | } |
||
49 | |||
50 | return new $this->valueObjectClass($direction); |
||
51 | } |
||
52 | } |
||
53 |