Passed
Push — master ( e68f99...117087 )
by Ben
07:39
created
src/Sets/SetReference.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     {
38 38
         // Constraints
39 39
         if (!isset($values['action'])) {
40
-            throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: ' . print_r($values, true));
40
+            throw new \InvalidArgumentException('Set reference array is missing required values for the "action" keys. Given: '.print_r($values, true));
41 41
         }
42 42
 
43 43
         return new static(
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
     {
53 53
         $sets = config('thinktomorrow.chief.sets', []);
54 54
 
55
-        return collect($sets)->map(function ($set, $key) {
55
+        return collect($sets)->map(function($set, $key) {
56 56
             return SetReference::fromArray($key, $set);
57 57
         });
58 58
     }
59 59
 
60 60
     public static function find($key): ?SetReference
61 61
     {
62
-        return static::all()->filter(function ($ref) use ($key) {
62
+        return static::all()->filter(function($ref) use ($key) {
63 63
             return $ref->key() == $key;
64 64
         })->first();
65 65
     }
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 
77 77
         $this->validateAction($class, $method);
78 78
 
79
-        $result = call_user_func_array([app($class),$method], $this->parameters($class, $method, $parent));
79
+        $result = call_user_func_array([app($class), $method], $this->parameters($class, $method, $parent));
80 80
 
81
-        if (! $result instanceof Set && $result instanceof Collection) {
81
+        if (!$result instanceof Set && $result instanceof Collection) {
82 82
             return new Set($result->all(), $this->key);
83 83
         }
84 84
 
@@ -93,22 +93,22 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function parameters(string $class, string $method, ActsAsParent $parent): array
95 95
     {
96
-        try{
96
+        try {
97 97
             $parameters = $this->parameters;
98 98
 
99 99
             $reflection = new \ReflectionClass($class);
100
-            foreach($reflection->getMethod($method)->getParameters() as $parameter){
101
-                if($parameter->getType() && $parameter->getType()->getName() == ActsAsParent::class){
100
+            foreach ($reflection->getMethod($method)->getParameters() as $parameter) {
101
+                if ($parameter->getType() && $parameter->getType()->getName() == ActsAsParent::class) {
102 102
                     $parameters[] = $parent;
103 103
                 }
104
-                if($parameter->getType() && $parameter->getType()->getName() == Request::class){
104
+                if ($parameter->getType() && $parameter->getType()->getName() == Request::class) {
105 105
                     $parameters[] = request();
106 106
                 }
107 107
             }
108 108
 
109 109
             return $parameters;
110 110
         }
111
-        catch(\Exception $e) {
111
+        catch (\Exception $e) {
112 112
             if (config('thinktomorrow.chief.strict')) {
113 113
                 throw $e;
114 114
             }
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
     private static function validateAction($class, $method)
144 144
     {
145
-        if (! class_exists($class)) {
145
+        if (!class_exists($class)) {
146 146
             throw new \InvalidArgumentException('The class ['.$class.'] isn\'t a valid class reference or does not exist in the chief-settings.sets config entry.');
147 147
         }
148 148
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -107,8 +107,7 @@
 block discarded – undo
107 107
             }
108 108
 
109 109
             return $parameters;
110
-        }
111
-        catch(\Exception $e) {
110
+        } catch(\Exception $e) {
112 111
             if (config('thinktomorrow.chief.strict')) {
113 112
                 throw $e;
114 113
             }
Please login to merge, or discard this patch.