| Conditions | 5 |
| Paths | 5 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 0 | ||
| 1 | <?php namespace Pz\LaravelDoctrine\Rest\Request; |
||
| 57 | public function getOrderBy() |
||
| 58 | { |
||
| 59 | if ($fields = explode(',', $this->get('sort'))) { |
||
| 60 | $orderBy = []; |
||
| 61 | |||
| 62 | foreach ($fields as $field) { |
||
| 63 | if (empty($field)) continue; |
||
| 64 | |||
| 65 | $direction = 'ASC'; |
||
| 66 | if ($field[0] === '-') { |
||
| 67 | $field = substr($field, 1); |
||
| 68 | $direction = 'DESC'; |
||
| 69 | } |
||
| 70 | |||
| 71 | $orderBy[$field] = $direction; |
||
| 72 | } |
||
| 73 | |||
| 74 | return $orderBy; |
||
| 75 | } |
||
| 76 | |||
| 77 | return null; |
||
| 78 | } |
||
| 96 |