Conditions | 8 |
Paths | 12 |
Total Lines | 21 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
12 | public function __construct($spec, $sortFieldsSpec) { |
||
13 | $expressions = []; |
||
14 | foreach($spec as $specReference => $dbExpr) { |
||
15 | if(is_int($specReference)) { |
||
16 | $specReference = $dbExpr; |
||
17 | } |
||
18 | $expressions[$specReference] = $dbExpr; |
||
19 | } |
||
20 | foreach($sortFieldsSpec as $sortFieldSpec) { |
||
21 | if(array_key_exists(0, $sortFieldSpec) && array_key_exists($sortFieldSpec[0], $expressions)) { |
||
22 | $direction = 'ASC'; |
||
23 | if(array_key_exists(1, $sortFieldSpec) && strtoupper($sortFieldSpec[1]) !== 'ASC') { |
||
24 | $direction = 'DESC'; |
||
25 | } |
||
26 | $this->fields[] = [ |
||
27 | $expressions[$sortFieldSpec[0]], |
||
28 | $direction |
||
29 | ]; |
||
30 | } |
||
31 | } |
||
32 | } |
||
33 | |||
44 |