| Conditions | 3 |
| Paths | 2 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | 6 | public function __construct(Request $request) |
|
| 17 | { |
||
| 18 | 6 | $paramName = config('request-query-helper.sort'); |
|
| 19 | |||
| 20 | 6 | $params = $request->filled($paramName) ? explode(',', $request->get($paramName)) : []; |
|
| 21 | |||
| 22 | $this->fields = collect($params)->map(function ($field) { |
||
| 23 | 6 | $direction = SortField::DIRECTION_ASCENDING; |
|
| 24 | |||
| 25 | 6 | if (Str::startsWith($field, '-')) { |
|
| 26 | 6 | $direction = SortField::DIRECTION_DESCENDING; |
|
| 27 | 6 | $field = Str::after($field, '-'); |
|
| 28 | } |
||
| 29 | |||
| 30 | 6 | return new SortField($field, $direction); |
|
| 31 | 6 | }); |
|
| 44 |