| @@ -42,24 +42,24 @@ discard block | ||
| 42 | 42 | // Go through the value and take out all the rules | 
| 43 | 43 | $rules = []; | 
| 44 | 44 | |
| 45 | -        while($rule = $this->takeNextSortRule($value)) { | |
| 45 | +        while ($rule = $this->takeNextSortRule($value)) { | |
| 46 | 46 | $rules[] = $rule; | 
| 47 | 47 | } | 
| 48 | 48 | |
| 49 | 49 | // Fail the validation if no rules were passed | 
| 50 | - if(!count($rules)) | |
| 50 | + if (!count($rules)) | |
| 51 | 51 |              return $this->fail('The :attribute contains no valid sorting rules.'); | 
| 52 | 52 | |
| 53 | -        foreach($rules as $rule) { | |
| 53 | +        foreach ($rules as $rule) { | |
| 54 | 54 | $column = $rule['column']; | 
| 55 | 55 | $direction = $rule['direction']; | 
| 56 | 56 | |
| 57 | 57 | // Validate that the column can be sorted on | 
| 58 | - if(!$this->sortableColumns->isValidColumn($column)) | |
| 58 | + if (!$this->sortableColumns->isValidColumn($column)) | |
| 59 | 59 |                  return $this->fail("'{$column}' cannot be sorted on."); | 
| 60 | 60 | |
| 61 | 61 | // Validate that the direction is valid | 
| 62 | - if(!$this->sortableColumns->isValidDirectionForColumn($column, $direction)) | |
| 62 | + if (!$this->sortableColumns->isValidDirectionForColumn($column, $direction)) | |
| 63 | 63 |                  return $this->fail("'{$direction}' is an invalid sorting direction for '{$column}'"); | 
| 64 | 64 | |
| 65 | 65 | // Validate whether the column is not present more than once | 
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 | return ($rule['column'] == $column); | 
| 68 | 68 | }); | 
| 69 | 69 | |
| 70 | - if(count($doubleRule) > 1) | |
| 70 | + if (count($doubleRule) > 1) | |
| 71 | 71 |                  return $this->fail("'{$direction}' should only have one sort rule."); | 
| 72 | 72 | } | 
| 73 | 73 | |
| @@ -107,7 +107,7 @@ discard block | ||
| 107 | 107 | */ | 
| 108 | 108 | private function takeNextSortRule(&$subject): ?array | 
| 109 | 109 |      { | 
| 110 | - if(preg_match(self::SORT_PATTERN, $subject, $match)) | |
| 110 | + if (preg_match(self::SORT_PATTERN, $subject, $match)) | |
| 111 | 111 |          { | 
| 112 | 112 | // Remove the match from the string | 
| 113 | 113 | $subject = preg_replace(self::SORT_PATTERN, '', $subject, 1); | 
| @@ -132,7 +132,7 @@ discard block | ||
| 132 | 132 |      { | 
| 133 | 133 | $collection = new SortableColumnCollection(); | 
| 134 | 134 | |
| 135 | -        foreach($columns as $left => $right) { | |
| 135 | +        foreach ($columns as $left => $right) { | |
| 136 | 136 | // ['columnName' => Sorter::class]; notation | 
| 137 | 137 |              if (is_string($left)) { | 
| 138 | 138 | // Redefine variables for clarity | 
| @@ -32,7 +32,7 @@ discard block | ||
| 32 | 32 |      { | 
| 33 | 33 | $column = $this->find($column); | 
| 34 | 34 | |
| 35 | -        if($column) { | |
| 35 | +        if ($column) { | |
| 36 | 36 | return in_array($direction, $column->sorter->getDirections()); | 
| 37 | 37 | } | 
| 38 | 38 | |
| @@ -47,8 +47,8 @@ discard block | ||
| 47 | 47 | */ | 
| 48 | 48 | function find(string $column): ?SortableColumn | 
| 49 | 49 |      { | 
| 50 | -        foreach($this->items as $item) { | |
| 51 | - if($item->name === $column) return $item; | |
| 50 | +        foreach ($this->items as $item) { | |
| 51 | + if ($item->name === $column) return $item; | |
| 52 | 52 | } | 
| 53 | 53 | |
| 54 | 54 | return null; | 
| @@ -48,7 +48,9 @@ | ||
| 48 | 48 | function find(string $column): ?SortableColumn | 
| 49 | 49 |      { | 
| 50 | 50 |          foreach($this->items as $item) { | 
| 51 | - if($item->name === $column) return $item; | |
| 51 | +            if($item->name === $column) { | |
| 52 | + return $item; | |
| 53 | + } | |
| 52 | 54 | } | 
| 53 | 55 | |
| 54 | 56 | return null; |