Passed
Push — master ( 47c627...033b76 )
by Anton
02:34
created
src/Domain/GuardInterceptor.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  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
             throw new ControllerException(
52 52
                 sprintf(
53 53
                     'Unauthorized permission `%s` for action `%s`->`%s`',
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
     private function getPermissions(string $controller, string $action): ?array
75 75
     {
76 76
         $key = sprintf('%s:%s', $controller, $action);
77
-        if (array_key_exists($key, $this->cache)) {
77
+        if (array_key_exists($key, $this->cache)){
78 78
             return $this->cache[$key];
79 79
         }
80 80
 
81 81
         $this->cache[$key] = null;
82
-        try {
82
+        try{
83 83
             $method = new \ReflectionMethod($controller, $action);
84
-        } catch (\ReflectionException $e) {
84
+        }catch (\ReflectionException $e){
85 85
             return null;
86 86
         }
87 87
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             Guarded::class
100 100
         );
101 101
 
102
-        if ($action === null) {
102
+        if ($action === null){
103 103
             return null;
104 104
         }
105 105
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
             ControllerException::FORBIDDEN
122 122
         ];
123 123
 
124
-        if ($guarded->permission === null && $ns === null) {
124
+        if ($guarded->permission === null && $ns === null){
125 125
             throw new InterceptorException(sprintf(
126 126
                 'Unable to apply @Guarded without name or @GuardNamespace on `%s`->`%s`',
127 127
                 $method->getDeclaringClass()->getName(),
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
             ));
130 130
         }
131 131
 
132
-        if ($ns !== null) {
132
+        if ($ns !== null){
133 133
             $permission[0] = sprintf('%s.%s', $ns->namespace, $permission[0]);
134 134
         }
135 135
 
136
-        switch ($guarded->else) {
136
+        switch ($guarded->else){
137 137
             case 'badAction':
138 138
                 $permission[1] = ControllerException::BAD_ACTION;
139 139
                 break;
Please login to merge, or discard this 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.