Passed
Push — master ( 47c627...033b76 )
by Anton
02:34
created
src/Domain/GuardInterceptor.php 1 patch
Braces   +17 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@  discard block
 block discarded – undo
47 47
     {
48 48
         $permission = $this->getPermissions($controller, $action);
49 49
 
50
-        if ($permission !== null && !$this->guard->allows($permission[0], $parameters)) {
50
+        if ($permission !== null && !$this->guard->allows($permission[0], $parameters))
51
+        {
51 52
             throw new ControllerException(
52 53
                 sprintf(
53 54
                     'Unauthorized permission `%s` for action `%s`->`%s`',
@@ -74,14 +75,18 @@  discard block
 block discarded – undo
74 75
     private function getPermissions(string $controller, string $action): ?array
75 76
     {
76 77
         $key = sprintf('%s:%s', $controller, $action);
77
-        if (array_key_exists($key, $this->cache)) {
78
+        if (array_key_exists($key, $this->cache))
79
+        {
78 80
             return $this->cache[$key];
79 81
         }
80 82
 
81 83
         $this->cache[$key] = null;
82
-        try {
84
+        try
85
+        {
83 86
             $method = new \ReflectionMethod($controller, $action);
84
-        } catch (\ReflectionException $e) {
87
+        }
88
+        catch (\ReflectionException $e)
89
+        {
85 90
             return null;
86 91
         }
87 92
 
@@ -99,7 +104,8 @@  discard block
 block discarded – undo
99 104
             Guarded::class
100 105
         );
101 106
 
102
-        if ($action === null) {
107
+        if ($action === null)
108
+        {
103 109
             return null;
104 110
         }
105 111
 
@@ -121,7 +127,8 @@  discard block
 block discarded – undo
121 127
             ControllerException::FORBIDDEN
122 128
         ];
123 129
 
124
-        if ($guarded->permission === null && $ns === null) {
130
+        if ($guarded->permission === null && $ns === null)
131
+        {
125 132
             throw new InterceptorException(sprintf(
126 133
                 'Unable to apply @Guarded without name or @GuardNamespace on `%s`->`%s`',
127 134
                 $method->getDeclaringClass()->getName(),
@@ -129,11 +136,13 @@  discard block
 block discarded – undo
129 136
             ));
130 137
         }
131 138
 
132
-        if ($ns !== null) {
139
+        if ($ns !== null)
140
+        {
133 141
             $permission[0] = sprintf('%s.%s', $ns->namespace, $permission[0]);
134 142
         }
135 143
 
136
-        switch ($guarded->else) {
144
+        switch ($guarded->else)
145
+        {
137 146
             case 'badAction':
138 147
                 $permission[1] = ControllerException::BAD_ACTION;
139 148
                 break;
Please login to merge, or discard this patch.