| Conditions | 2 | 
| Paths | 1 | 
| Total Lines | 16 | 
| Code Lines | 10 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 7 | 
| CRAP Score | 2 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 14 | public function __construct(string $sorts = null) | ||
| 15 |     { | ||
| 16 | 6 | $this->fields = Collection::make(); | |
| 17 | $sorts = (new QueryParamBag($sorts))->getParams(); | ||
| 18 | 6 | $fields = array_keys($sorts); | |
| 19 | |||
| 20 | 6 |         collect($fields)->each(function (string $field) use ($sorts) { | |
| 21 | $params = $sorts[$field]; | ||
| 22 | $direction = SortField::DIRECTION_ASCENDING; | ||
| 23 | 6 | ||
| 24 |             if (Str::startsWith($field, '-')) { | ||
| 25 | 6 | $direction = SortField::DIRECTION_DESCENDING; | |
| 26 | 6 | $field = Str::after($field, '-'); | |
| 27 | 6 | } | |
| 28 | |||
| 29 | $this->fields->push(new SortField($field, $direction, $params)); | ||
| 30 | 6 | }); | |
| 38 |