Passed
Pull Request — master (#737)
by butschster
06:46
created
src/Framework/Domain/FilterInterceptor.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,20 +37,20 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
39 39
     {
40
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
41
-            if (isset($parameters[$parameter])) {
40
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
41
+            if (isset($parameters[$parameter])){
42 42
                 continue;
43 43
             }
44 44
 
45 45
             /** @var FilterInterface $filter */
46 46
             $filter = $this->container->get($filterClass);
47 47
 
48
-            if (isset($parameters['@context'])) {
48
+            if (isset($parameters['@context'])){
49 49
                 // other interceptors can define the validation contex
50 50
                 $filter->setContext($parameters['@context']);
51 51
             }
52 52
 
53
-            if (!$filter->isValid()) {
53
+            if (!$filter->isValid()){
54 54
                 return $this->renderInvalid($filter);
55 55
             }
56 56
 
@@ -79,25 +79,25 @@  discard block
 block discarded – undo
79 79
     private function getDeclaredFilters(string $controller, string $action): array
80 80
     {
81 81
         $key = sprintf('%s:%s', $controller, $action);
82
-        if (array_key_exists($key, $this->cache)) {
82
+        if (array_key_exists($key, $this->cache)){
83 83
             return $this->cache[$key];
84 84
         }
85 85
 
86 86
         $this->cache[$key] = [];
87
-        try {
87
+        try{
88 88
             $method = new \ReflectionMethod($controller, $action);
89
-        } catch (\ReflectionException $e) {
89
+        }catch (\ReflectionException $e){
90 90
             return [];
91 91
         }
92 92
 
93
-        foreach ($method->getParameters() as $parameter) {
93
+        foreach ($method->getParameters() as $parameter){
94 94
             $class = $this->getParameterClass($parameter);
95 95
 
96
-            if ($class === null) {
96
+            if ($class === null){
97 97
                 continue;
98 98
             }
99 99
 
100
-            if ($class->implementsInterface(FilterInterface::class)) {
100
+            if ($class->implementsInterface(FilterInterface::class)){
101 101
                 $this->buildCache($parameter, $class, $key);
102 102
             }
103 103
         }
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
     {
116 116
         $type = $parameter->getType();
117 117
 
118
-        if (!$type instanceof \ReflectionNamedType) {
118
+        if (!$type instanceof \ReflectionNamedType){
119 119
             return null;
120 120
         }
121 121
 
122
-        if ($type->isBuiltin()) {
122
+        if ($type->isBuiltin()){
123 123
             return null;
124 124
         }
125 125
 
Please login to merge, or discard this patch.
Braces   +25 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,20 +37,24 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
39 39
     {
40
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
41
-            if (isset($parameters[$parameter])) {
40
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
41
+        {
42
+            if (isset($parameters[$parameter]))
43
+            {
42 44
                 continue;
43 45
             }
44 46
 
45 47
             /** @var FilterInterface $filter */
46 48
             $filter = $this->container->get($filterClass);
47 49
 
48
-            if (isset($parameters['@context'])) {
50
+            if (isset($parameters['@context']))
51
+            {
49 52
                 // other interceptors can define the validation contex
50 53
                 $filter->setContext($parameters['@context']);
51 54
             }
52 55
 
53
-            if (!$filter->isValid()) {
56
+            if (!$filter->isValid())
57
+            {
54 58
                 return $this->renderInvalid($filter);
55 59
             }
56 60
 
@@ -79,25 +83,32 @@  discard block
 block discarded – undo
79 83
     private function getDeclaredFilters(string $controller, string $action): array
80 84
     {
81 85
         $key = sprintf('%s:%s', $controller, $action);
82
-        if (array_key_exists($key, $this->cache)) {
86
+        if (array_key_exists($key, $this->cache))
87
+        {
83 88
             return $this->cache[$key];
84 89
         }
85 90
 
86 91
         $this->cache[$key] = [];
87
-        try {
92
+        try
93
+        {
88 94
             $method = new \ReflectionMethod($controller, $action);
89
-        } catch (\ReflectionException $e) {
95
+        }
96
+        catch (\ReflectionException $e)
97
+        {
90 98
             return [];
91 99
         }
92 100
 
93
-        foreach ($method->getParameters() as $parameter) {
101
+        foreach ($method->getParameters() as $parameter)
102
+        {
94 103
             $class = $this->getParameterClass($parameter);
95 104
 
96
-            if ($class === null) {
105
+            if ($class === null)
106
+            {
97 107
                 continue;
98 108
             }
99 109
 
100
-            if ($class->implementsInterface(FilterInterface::class)) {
110
+            if ($class->implementsInterface(FilterInterface::class))
111
+            {
101 112
                 $this->buildCache($parameter, $class, $key);
102 113
             }
103 114
         }
@@ -115,11 +126,13 @@  discard block
 block discarded – undo
115 126
     {
116 127
         $type = $parameter->getType();
117 128
 
118
-        if (!$type instanceof \ReflectionNamedType) {
129
+        if (!$type instanceof \ReflectionNamedType)
130
+        {
119 131
             return null;
120 132
         }
121 133
 
122
-        if ($type->isBuiltin()) {
134
+        if ($type->isBuiltin())
135
+        {
123 136
             return null;
124 137
         }
125 138
 
Please login to merge, or discard this patch.