Passed
Pull Request — master (#2)
by
unknown
07:08
created
src/SortRequestServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
      */
38 38
     private function registerMacros()
39 39
     {
40
-        Builder::macro('sortViaRequest', function ($request) {
40
+        Builder::macro('sortViaRequest', function($request) {
41 41
             $handler = new EloquentSortingHandler($request, $this);
42 42
 
43 43
             return $handler->handle();
Please login to merge, or discard this patch.
src/Console/SorterMakeCommand.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@
 block discarded – undo
50 50
             $this->files->put($path, $this->buildClass($name));
51 51
         }
52 52
 
53
-        $this->info($this->type.' created successfully.');
53
+        $this->info($this->type . ' created successfully.');
54 54
     }
55 55
 
56 56
     /**
Please login to merge, or discard this patch.
src/EloquentSortingHandler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $this->checkForTrait();
42 42
 
43 43
         // Loop through every rule and handle it individually
44
-        foreach($this->rules as $rule)
44
+        foreach ($this->rules as $rule)
45 45
         {
46 46
             // Find the relevant sortable column for this rule
47 47
             $sortableColumn = $this->sortableColumns->find($rule['column']);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     private function checkForTrait()
76 76
     {
77
-        if(!method_exists($this->request, 'validatedSortingRules')) {
77
+        if (!method_exists($this->request, 'validatedSortingRules')) {
78 78
             $requestClass = get_class($this->request);
79 79
 
80 80
             throw new EloquentSortingException("{$requestClass} is not using the SortsViaRequest trait.");
Please login to merge, or discard this patch.
src/Rules/SortParameter.php 2 patches
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,28 +46,32 @@
 block discarded – undo
46 46
         }
47 47
 
48 48
         // Fail the validation if no rules were passed
49
-        if(!count($rules))
50
-            return $this->fail('The :attribute contains no valid sorting rules.');
49
+        if(!count($rules)) {
50
+                    return $this->fail('The :attribute contains no valid sorting rules.');
51
+        }
51 52
 
52 53
         foreach($rules as $rule) {
53 54
             $column = $rule['column'];
54 55
             $direction = $rule['direction'];
55 56
 
56 57
             // Validate that the column can be sorted on
57
-            if(!$this->sortableColumns->isValidColumn($column))
58
-                return $this->fail("'{$column}' cannot be sorted on.");
58
+            if(!$this->sortableColumns->isValidColumn($column)) {
59
+                            return $this->fail("'{$column}' cannot be sorted on.");
60
+            }
59 61
 
60 62
             // Validate that the direction is valid
61
-            if(!$this->sortableColumns->isValidDirectionForColumn($column, $direction))
62
-                return $this->fail("'{$direction}' is an invalid sorting direction for '{$column}'");
63
+            if(!$this->sortableColumns->isValidDirectionForColumn($column, $direction)) {
64
+                            return $this->fail("'{$direction}' is an invalid sorting direction for '{$column}'");
65
+            }
63 66
 
64 67
             // Validate whether the column is not present more than once
65 68
             $doubleRule = array_filter($rules, function($rule) use($column) {
66 69
                 return ($rule['column'] == $column);
67 70
             });
68 71
 
69
-            if(count($doubleRule) > 1)
70
-                return $this->fail("'{$direction}' should only have one sort rule.");
72
+            if(count($doubleRule) > 1) {
73
+                            return $this->fail("'{$direction}' should only have one sort rule.");
74
+            }
71 75
         }
72 76
 
73 77
         $this->sortingRules = $rules;
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -42,24 +42,24 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Traits/SortsViaRequest.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     /** @noinspection PhpUnhandledExceptionInspection */
22 22
     public function __construct()
23 23
     {
24
-        if(!($this instanceof FormRequest))
24
+        if (!($this instanceof FormRequest))
25 25
             throw new BadTraitImplementation(__TRAIT__);
26 26
 
27 27
         // Create an instance of the validation rule
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,8 +21,9 @@
 block discarded – undo
21 21
     /** @noinspection PhpUnhandledExceptionInspection */
22 22
     public function __construct()
23 23
     {
24
-        if(!($this instanceof FormRequest))
25
-            throw new BadTraitImplementation(__TRAIT__);
24
+        if(!($this instanceof FormRequest)) {
25
+                    throw new BadTraitImplementation(__TRAIT__);
26
+        }
26 27
 
27 28
         // Create an instance of the validation rule
28 29
         $this->sortParameterRule = new SortParameter($this->getSortableColumns());
Please login to merge, or discard this patch.
src/SortableColumnCollection.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,9 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.