Passed
Push — master ( 2291e3...cd7158 )
by Anton
03:34
created
src/Filters/src/SchemaBuilder.php 3 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,16 +69,16 @@  discard block
 block discarded – undo
69 69
     protected function buildMap(ReflectionEntity $filter): array
70 70
     {
71 71
         $schema = $filter->getProperty('schema', true);
72
-        if (empty($schema)) {
72
+        if (empty($schema)){
73 73
             throw new SchemaException("Filter `{$filter->getName()}` does not define any schema");
74 74
         }
75 75
 
76 76
         $result = [];
77
-        foreach ($schema as $field => $definition) {
77
+        foreach ($schema as $field => $definition){
78 78
             // short definition
79
-            if (is_string($definition)) {
79
+            if (is_string($definition)){
80 80
                 // simple scalar field definition
81
-                if (!class_exists($definition)) {
81
+                if (!class_exists($definition)){
82 82
                     [$source, $origin] = $this->parseDefinition($filter, $field, $definition);
83 83
                     $result[$field] = [
84 84
                         FilterProvider::SOURCE => $source,
@@ -98,20 +98,20 @@  discard block
 block discarded – undo
98 98
                 continue;
99 99
             }
100 100
 
101
-            if (!is_array($definition) || count($definition) === 0) {
101
+            if (!is_array($definition) || count($definition) === 0){
102 102
                 throw new SchemaException(
103 103
                     "Invalid schema definition at `{$filter->getName()}`->`{$field}`"
104 104
                 );
105 105
             }
106 106
 
107 107
             // complex definition
108
-            if (!empty($definition[self::ORIGIN])) {
108
+            if (!empty($definition[self::ORIGIN])){
109 109
                 $origin = $definition[self::ORIGIN];
110 110
 
111 111
                 // [class, 'data:something.*'] vs [class, 'data:something']
112 112
                 $iterate = strpos($origin, '.*') !== false || !empty($definition[self::ITERATE]);
113 113
                 $origin = rtrim($origin, '.*');
114
-            } else {
114
+            }else{
115 115
                 $origin = $field;
116 116
                 $iterate = true;
117 117
             }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                 FilterProvider::ARRAY  => $iterate
125 125
             ];
126 126
 
127
-            if ($iterate) {
127
+            if ($iterate){
128 128
                 [$source, $origin] = $this->parseDefinition(
129 129
                     $filter,
130 130
                     $field,
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      */
156 156
     private function parseDefinition(ReflectionEntity $filter, string $field, string $definition): array
157 157
     {
158
-        if (strpos($definition, ':') === false) {
158
+        if (strpos($definition, ':') === false){
159 159
             return ['data', $definition ?? $field];
160 160
         }
161 161
 
Please login to merge, or discard this patch.
Braces   +19 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,16 +69,20 @@  discard block
 block discarded – undo
69 69
     protected function buildMap(ReflectionEntity $filter): array
70 70
     {
71 71
         $schema = $filter->getProperty('schema', true);
72
-        if (empty($schema)) {
72
+        if (empty($schema))
73
+        {
73 74
             throw new SchemaException("Filter `{$filter->getName()}` does not define any schema");
74 75
         }
75 76
 
76 77
         $result = [];
77
-        foreach ($schema as $field => $definition) {
78
+        foreach ($schema as $field => $definition)
79
+        {
78 80
             // short definition
79
-            if (is_string($definition)) {
81
+            if (is_string($definition))
82
+            {
80 83
                 // simple scalar field definition
81
-                if (!class_exists($definition)) {
84
+                if (!class_exists($definition))
85
+                {
82 86
                     [$source, $origin] = $this->parseDefinition($filter, $field, $definition);
83 87
                     $result[$field] = [
84 88
                         FilterProvider::SOURCE => $source,
@@ -98,20 +102,24 @@  discard block
 block discarded – undo
98 102
                 continue;
99 103
             }
100 104
 
101
-            if (!is_array($definition) || count($definition) === 0) {
105
+            if (!is_array($definition) || count($definition) === 0)
106
+            {
102 107
                 throw new SchemaException(
103 108
                     "Invalid schema definition at `{$filter->getName()}`->`{$field}`"
104 109
                 );
105 110
             }
106 111
 
107 112
             // complex definition
108
-            if (!empty($definition[self::ORIGIN])) {
113
+            if (!empty($definition[self::ORIGIN]))
114
+            {
109 115
                 $origin = $definition[self::ORIGIN];
110 116
 
111 117
                 // [class, 'data:something.*'] vs [class, 'data:something']
112 118
                 $iterate = strpos($origin, '.*') !== false || !empty($definition[self::ITERATE]);
113 119
                 $origin = rtrim($origin, '.*');
114
-            } else {
120
+            }
121
+            else
122
+            {
115 123
                 $origin = $field;
116 124
                 $iterate = true;
117 125
             }
@@ -124,7 +132,8 @@  discard block
 block discarded – undo
124 132
                 FilterProvider::ARRAY  => $iterate
125 133
             ];
126 134
 
127
-            if ($iterate) {
135
+            if ($iterate)
136
+            {
128 137
                 [$source, $origin] = $this->parseDefinition(
129 138
                     $filter,
130 139
                     $field,
@@ -155,7 +164,8 @@  discard block
 block discarded – undo
155 164
      */
156 165
     private function parseDefinition(ReflectionEntity $filter, string $field, string $definition): array
157 166
     {
158
-        if (strpos($definition, ':') === false) {
167
+        if (strpos($definition, ':') === false)
168
+        {
159 169
             return ['data', $definition ?? $field];
160 170
         }
161 171
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                     FilterProvider::SOURCE => null,
93 93
                     FilterProvider::ORIGIN => $field,
94 94
                     FilterProvider::FILTER => $definition,
95
-                    FilterProvider::ARRAY  => false
95
+                    FilterProvider::array  => false
96 96
                 ];
97 97
 
98 98
                 continue;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 FilterProvider::FILTER => $definition[self::NESTED],
122 122
                 FilterProvider::SOURCE => null,
123 123
                 FilterProvider::ORIGIN => $origin,
124
-                FilterProvider::ARRAY  => $iterate
124
+                FilterProvider::array  => $iterate
125 125
             ];
126 126
 
127 127
             if ($iterate) {
Please login to merge, or discard this patch.
src/Filters/src/ErrorMapper.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
     {
38 38
         //De-mapping
39 39
         $mapped = [];
40
-        foreach ($errors as $field => $message) {
41
-            if (!isset($this->schema[$field])) {
40
+        foreach ($errors as $field => $message){
41
+            if (!isset($this->schema[$field])){
42 42
                 $mapped[$field] = $message;
43 43
                 continue;
44 44
             }
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function mount(array &$array, string $path, $message): void
62 62
     {
63
-        if ($path === '.') {
63
+        if ($path === '.'){
64 64
             throw new SchemaException(
65 65
                 "Unable to mount error `{$message}` to `{$path}` (root path is forbidden)"
66 66
             );
67 67
         }
68 68
 
69 69
         $step = explode('.', $path);
70
-        while ($name = array_shift($step)) {
70
+        while ($name = array_shift($step)){
71 71
             $array = &$array[$name];
72 72
         }
73 73
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,8 +37,10 @@  discard block
 block discarded – undo
37 37
     {
38 38
         //De-mapping
39 39
         $mapped = [];
40
-        foreach ($errors as $field => $message) {
41
-            if (!isset($this->schema[$field])) {
40
+        foreach ($errors as $field => $message)
41
+        {
42
+            if (!isset($this->schema[$field]))
43
+            {
42 44
                 $mapped[$field] = $message;
43 45
                 continue;
44 46
             }
@@ -60,14 +62,16 @@  discard block
 block discarded – undo
60 62
      */
61 63
     private function mount(array &$array, string $path, $message): void
62 64
     {
63
-        if ($path === '.') {
65
+        if ($path === '.')
66
+        {
64 67
             throw new SchemaException(
65 68
                 "Unable to mount error `{$message}` to `{$path}` (root path is forbidden)"
66 69
             );
67 70
         }
68 71
 
69 72
         $step = explode('.', $path);
70
-        while ($name = array_shift($step)) {
73
+        while ($name = array_shift($step))
74
+        {
71 75
             $array = &$array[$name];
72 76
         }
73 77
 
Please login to merge, or discard this patch.
src/Filters/src/ArrayInput.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
     public function withPrefix(string $prefix, bool $add = true): InputInterface
39 39
     {
40 40
         $input = clone $this;
41
-        if ($add) {
42
-            $input->prefix .= '.' . $prefix;
41
+        if ($add){
42
+            $input->prefix .= '.'.$prefix;
43 43
             $input->prefix = trim($input->prefix, '.');
44
-        } else {
44
+        }else{
45 45
             $input->prefix = $prefix;
46 46
         }
47 47
         return $input;
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function getValue(string $source, string $name = null)
54 54
     {
55
-        try {
55
+        try{
56 56
             return $this->dotGet($name);
57
-        } catch (DotNotFoundException $e) {
57
+        }catch (DotNotFoundException $e){
58 58
             return null;
59 59
         }
60 60
     }
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
         $data = $this->data;
73 73
 
74 74
         //Generating path relative to a given name and prefix
75
-        $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name;
76
-        if (empty($path)) {
75
+        $path = (!empty($this->prefix) ? $this->prefix.'.' : '').$name;
76
+        if (empty($path)){
77 77
             return $data;
78 78
         }
79 79
 
80 80
         $path = explode('.', rtrim($path, '.'));
81
-        foreach ($path as $step) {
82
-            if (!is_array($data) || !array_key_exists($step, $data)) {
81
+        foreach ($path as $step){
82
+            if (!is_array($data) || !array_key_exists($step, $data)){
83 83
                 throw new DotNotFoundException("Unable to find requested element '{$name}'");
84 84
             }
85 85
             $data = &$data[$step];
Please login to merge, or discard this patch.
Braces   +16 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,10 +38,13 @@  discard block
 block discarded – undo
38 38
     public function withPrefix(string $prefix, bool $add = true): InputInterface
39 39
     {
40 40
         $input = clone $this;
41
-        if ($add) {
41
+        if ($add)
42
+        {
42 43
             $input->prefix .= '.' . $prefix;
43 44
             $input->prefix = trim($input->prefix, '.');
44
-        } else {
45
+        }
46
+        else
47
+        {
45 48
             $input->prefix = $prefix;
46 49
         }
47 50
         return $input;
@@ -52,9 +55,12 @@  discard block
 block discarded – undo
52 55
      */
53 56
     public function getValue(string $source, string $name = null)
54 57
     {
55
-        try {
58
+        try
59
+        {
56 60
             return $this->dotGet($name);
57
-        } catch (DotNotFoundException $e) {
61
+        }
62
+        catch (DotNotFoundException $e)
63
+        {
58 64
             return null;
59 65
         }
60 66
     }
@@ -73,13 +79,16 @@  discard block
 block discarded – undo
73 79
 
74 80
         //Generating path relative to a given name and prefix
75 81
         $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name;
76
-        if (empty($path)) {
82
+        if (empty($path))
83
+        {
77 84
             return $data;
78 85
         }
79 86
 
80 87
         $path = explode('.', rtrim($path, '.'));
81
-        foreach ($path as $step) {
82
-            if (!is_array($data) || !array_key_exists($step, $data)) {
88
+        foreach ($path as $step)
89
+        {
90
+            if (!is_array($data) || !array_key_exists($step, $data))
91
+            {
83 92
                 throw new DotNotFoundException("Unable to find requested element '{$name}'");
84 93
             }
85 94
             $data = &$data[$step];
Please login to merge, or discard this patch.
src/Filters/src/Filter.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         array $schema,
87 87
         ValidatorInterface $validator,
88 88
         ErrorMapper $errorMapper
89
-    ) {
89
+    ){
90 90
         parent::__construct($data, $schema);
91 91
         $this->validator = $validator;
92 92
         $this->errorMapper = $errorMapper;
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function getErrors(): array
157 157
     {
158
-        if ($this->errors === null) {
158
+        if ($this->errors === null){
159 159
             $this->errors = [];
160
-            foreach ($this->validator->withData($this)->getErrors() as $field => $error) {
161
-                if (is_string($error) && Translator::isMessage($error)) {
160
+            foreach ($this->validator->withData($this)->getErrors() as $field => $error){
161
+                if (is_string($error) && Translator::isMessage($error)){
162 162
                     // translate error message
163 163
                     $error = $this->say($error);
164 164
                 }
@@ -190,21 +190,21 @@  discard block
 block discarded – undo
190 190
      */
191 191
     protected function validateNested(array $errors): array
192 192
     {
193
-        foreach ($this->getFields(false) as $index => $value) {
194
-            if (isset($errors[$index])) {
193
+        foreach ($this->getFields(false) as $index => $value){
194
+            if (isset($errors[$index])){
195 195
                 //Invalid on parent level
196 196
                 continue;
197 197
             }
198 198
 
199
-            if ($value instanceof FilterInterface && !$value->isValid()) {
199
+            if ($value instanceof FilterInterface && !$value->isValid()){
200 200
                 $errors[$index] = $value->getErrors();
201 201
                 continue;
202 202
             }
203 203
 
204 204
             //Array of nested entities for validation
205
-            if (is_iterable($value)) {
206
-                foreach ($value as $nIndex => $nValue) {
207
-                    if ($nValue instanceof FilterInterface && !$nValue->isValid()) {
205
+            if (is_iterable($value)){
206
+                foreach ($value as $nIndex => $nValue){
207
+                    if ($nValue instanceof FilterInterface && !$nValue->isValid()){
208 208
                         $errors[$index][$nIndex] = $nValue->getErrors();
209 209
                     }
210 210
                 }
Please login to merge, or discard this patch.
Braces   +18 added lines, -9 removed lines patch added patch discarded remove patch
@@ -155,10 +155,13 @@  discard block
 block discarded – undo
155 155
      */
156 156
     public function getErrors(): array
157 157
     {
158
-        if ($this->errors === null) {
158
+        if ($this->errors === null)
159
+        {
159 160
             $this->errors = [];
160
-            foreach ($this->validator->withData($this)->getErrors() as $field => $error) {
161
-                if (is_string($error) && Translator::isMessage($error)) {
161
+            foreach ($this->validator->withData($this)->getErrors() as $field => $error)
162
+            {
163
+                if (is_string($error) && Translator::isMessage($error))
164
+                {
162 165
                     // translate error message
163 166
                     $error = $this->say($error);
164 167
                 }
@@ -190,21 +193,27 @@  discard block
 block discarded – undo
190 193
      */
191 194
     protected function validateNested(array $errors): array
192 195
     {
193
-        foreach ($this->getFields(false) as $index => $value) {
194
-            if (isset($errors[$index])) {
196
+        foreach ($this->getFields(false) as $index => $value)
197
+        {
198
+            if (isset($errors[$index]))
199
+            {
195 200
                 //Invalid on parent level
196 201
                 continue;
197 202
             }
198 203
 
199
-            if ($value instanceof FilterInterface && !$value->isValid()) {
204
+            if ($value instanceof FilterInterface && !$value->isValid())
205
+            {
200 206
                 $errors[$index] = $value->getErrors();
201 207
                 continue;
202 208
             }
203 209
 
204 210
             //Array of nested entities for validation
205
-            if (is_iterable($value)) {
206
-                foreach ($value as $nIndex => $nValue) {
207
-                    if ($nValue instanceof FilterInterface && !$nValue->isValid()) {
211
+            if (is_iterable($value))
212
+            {
213
+                foreach ($value as $nIndex => $nValue)
214
+                {
215
+                    if ($nValue instanceof FilterInterface && !$nValue->isValid())
216
+                    {
208 217
                         $errors[$index][$nIndex] = $nValue->getErrors();
209 218
                     }
210 219
                 }
Please login to merge, or discard this patch.
src/Filters/src/FilterProvider.php 3 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -91,18 +91,18 @@  discard block
 block discarded – undo
91 91
     public function initValues(array $mappingSchema, InputInterface $input): array
92 92
     {
93 93
         $result = [];
94
-        foreach ($mappingSchema as $field => $map) {
95
-            if (empty($map[self::FILTER])) {
94
+        foreach ($mappingSchema as $field => $map){
95
+            if (empty($map[self::FILTER])){
96 96
                 $value = $input->getValue($map[self::SOURCE], $map[self::ORIGIN]);
97 97
 
98
-                if ($value !== null) {
98
+                if ($value !== null){
99 99
                     $result[$field] = $value;
100 100
                 }
101 101
                 continue;
102 102
             }
103 103
 
104 104
             $nested = $map[self::FILTER];
105
-            if (empty($map[self::ARRAY])) {
105
+            if (empty($map[self::ARRAY])){
106 106
                 // slicing down
107 107
                 $result[$field] = $this->createFilter($nested, $input->withPrefix($map[self::ORIGIN]));
108 108
                 continue;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             $values = [];
112 112
 
113 113
             // List of "key" => "location in request"
114
-            foreach ($this->iterate($map, $input) as $index => $origin) {
114
+            foreach ($this->iterate($map, $input) as $index => $origin){
115 115
                 $values[$index] = $this->createFilter($nested, $input->withPrefix($origin));
116 116
             }
117 117
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
     private function iterate(array $schema, InputInterface $input): Generator
132 132
     {
133 133
         $values = $input->getValue($schema[self::ITERATE_SOURCE], $schema[self::ITERATE_ORIGIN]);
134
-        if (empty($values) || !is_array($values)) {
134
+        if (empty($values) || !is_array($values)){
135 135
             return [];
136 136
         }
137 137
 
138
-        foreach (array_keys($values) as $key) {
139
-            yield $key => $schema[self::ORIGIN] . '.' . $key;
138
+        foreach (array_keys($values) as $key){
139
+            yield $key => $schema[self::ORIGIN].'.'.$key;
140 140
         }
141 141
     }
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     private function getErrorMapper(string $filter): ErrorMapper
148 148
     {
149
-        if (isset($this->errorMappers[$filter])) {
149
+        if (isset($this->errorMappers[$filter])){
150 150
             return $this->errorMappers[$filter];
151 151
         }
152 152
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      */
163 163
     private function getValidator(string $filter): ValidatorInterface
164 164
     {
165
-        if (isset($this->validators[$filter])) {
165
+        if (isset($this->validators[$filter])){
166 166
             return $this->validators[$filter];
167 167
         }
168 168
 
@@ -180,18 +180,18 @@  discard block
 block discarded – undo
180 180
      */
181 181
     private function getSchema(string $filter): array
182 182
     {
183
-        if (isset($this->cache[$filter])) {
183
+        if (isset($this->cache[$filter])){
184 184
             return $this->cache[$filter];
185 185
         }
186 186
 
187
-        try {
187
+        try{
188 188
             $reflection = new ReflectionEntity($filter);
189
-            if (!$reflection->getReflection()->isSubclassOf(Filter::class)) {
189
+            if (!$reflection->getReflection()->isSubclassOf(Filter::class)){
190 190
                 throw new SchemaException('Invalid filter class, must be subclass of Filter');
191 191
             }
192 192
 
193 193
             $builder = new SchemaBuilder(new ReflectionEntity($filter));
194
-        } catch (ReflectionException $e) {
194
+        }catch (ReflectionException $e){
195 195
             throw new SchemaException('Invalid filter schema', $e->getCode(), $e);
196 196
         }
197 197
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -13 removed lines patch added patch discarded remove patch
@@ -91,18 +91,22 @@  discard block
 block discarded – undo
91 91
     public function initValues(array $mappingSchema, InputInterface $input): array
92 92
     {
93 93
         $result = [];
94
-        foreach ($mappingSchema as $field => $map) {
95
-            if (empty($map[self::FILTER])) {
94
+        foreach ($mappingSchema as $field => $map)
95
+        {
96
+            if (empty($map[self::FILTER]))
97
+            {
96 98
                 $value = $input->getValue($map[self::SOURCE], $map[self::ORIGIN]);
97 99
 
98
-                if ($value !== null) {
100
+                if ($value !== null)
101
+                {
99 102
                     $result[$field] = $value;
100 103
                 }
101 104
                 continue;
102 105
             }
103 106
 
104 107
             $nested = $map[self::FILTER];
105
-            if (empty($map[self::ARRAY])) {
108
+            if (empty($map[self::ARRAY]))
109
+            {
106 110
                 // slicing down
107 111
                 $result[$field] = $this->createFilter($nested, $input->withPrefix($map[self::ORIGIN]));
108 112
                 continue;
@@ -111,7 +115,8 @@  discard block
 block discarded – undo
111 115
             $values = [];
112 116
 
113 117
             // List of "key" => "location in request"
114
-            foreach ($this->iterate($map, $input) as $index => $origin) {
118
+            foreach ($this->iterate($map, $input) as $index => $origin)
119
+            {
115 120
                 $values[$index] = $this->createFilter($nested, $input->withPrefix($origin));
116 121
             }
117 122
 
@@ -131,11 +136,13 @@  discard block
 block discarded – undo
131 136
     private function iterate(array $schema, InputInterface $input): Generator
132 137
     {
133 138
         $values = $input->getValue($schema[self::ITERATE_SOURCE], $schema[self::ITERATE_ORIGIN]);
134
-        if (empty($values) || !is_array($values)) {
139
+        if (empty($values) || !is_array($values))
140
+        {
135 141
             return [];
136 142
         }
137 143
 
138
-        foreach (array_keys($values) as $key) {
144
+        foreach (array_keys($values) as $key)
145
+        {
139 146
             yield $key => $schema[self::ORIGIN] . '.' . $key;
140 147
         }
141 148
     }
@@ -146,7 +153,8 @@  discard block
 block discarded – undo
146 153
      */
147 154
     private function getErrorMapper(string $filter): ErrorMapper
148 155
     {
149
-        if (isset($this->errorMappers[$filter])) {
156
+        if (isset($this->errorMappers[$filter]))
157
+        {
150 158
             return $this->errorMappers[$filter];
151 159
         }
152 160
 
@@ -162,7 +170,8 @@  discard block
 block discarded – undo
162 170
      */
163 171
     private function getValidator(string $filter): ValidatorInterface
164 172
     {
165
-        if (isset($this->validators[$filter])) {
173
+        if (isset($this->validators[$filter]))
174
+        {
166 175
             return $this->validators[$filter];
167 176
         }
168 177
 
@@ -180,18 +189,23 @@  discard block
 block discarded – undo
180 189
      */
181 190
     private function getSchema(string $filter): array
182 191
     {
183
-        if (isset($this->cache[$filter])) {
192
+        if (isset($this->cache[$filter]))
193
+        {
184 194
             return $this->cache[$filter];
185 195
         }
186 196
 
187
-        try {
197
+        try
198
+        {
188 199
             $reflection = new ReflectionEntity($filter);
189
-            if (!$reflection->getReflection()->isSubclassOf(Filter::class)) {
200
+            if (!$reflection->getReflection()->isSubclassOf(Filter::class))
201
+            {
190 202
                 throw new SchemaException('Invalid filter class, must be subclass of Filter');
191 203
             }
192 204
 
193 205
             $builder = new SchemaBuilder(new ReflectionEntity($filter));
194
-        } catch (ReflectionException $e) {
206
+        }
207
+        catch (ReflectionException $e)
208
+        {
195 209
             throw new SchemaException('Invalid filter schema', $e->getCode(), $e);
196 210
         }
197 211
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     public const SOURCE         = 'source';
34 34
     public const ORIGIN         = 'origin';
35 35
     public const FILTER         = 'filter';
36
-    public const ARRAY          = 'array';
36
+    public const array          = 'array';
37 37
     public const ITERATE_SOURCE = 'iterate_source';
38 38
     public const ITERATE_ORIGIN = 'iterate_origin';
39 39
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             }
103 103
 
104 104
             $nested = $map[self::FILTER];
105
-            if (empty($map[self::ARRAY])) {
105
+            if (empty($map[self::array])) {
106 106
                 // slicing down
107 107
                 $result[$field] = $this->createFilter($nested, $input->withPrefix($map[self::ORIGIN]));
108 108
                 continue;
Please login to merge, or discard this patch.
src/Hmvc/tests/DemoInterceptor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,6 +18,6 @@
 block discarded – undo
18 18
 {
19 19
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
20 20
     {
21
-        return '?' . $core->callAction($controller, $action, $parameters) . '!';
21
+        return '?'.$core->callAction($controller, $action, $parameters).'!';
22 22
     }
23 23
 }
Please login to merge, or discard this patch.
src/Hmvc/src/InterceptorPipeline.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,12 +56,12 @@
 block discarded – undo
56 56
      */
57 57
     public function callAction(string $controller, string $action, array $parameters = [])
58 58
     {
59
-        if ($this->core === null) {
59
+        if ($this->core === null){
60 60
             throw new InterceptorException('Unable to invoke pipeline without assigned core');
61 61
         }
62 62
 
63 63
         $position = $this->position++;
64
-        if (isset($this->interceptors[$position])) {
64
+        if (isset($this->interceptors[$position])){
65 65
             return $this->interceptors[$position]->process($controller, $action, $parameters, $this);
66 66
         }
67 67
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -56,12 +56,14 @@
 block discarded – undo
56 56
      */
57 57
     public function callAction(string $controller, string $action, array $parameters = [])
58 58
     {
59
-        if ($this->core === null) {
59
+        if ($this->core === null)
60
+        {
60 61
             throw new InterceptorException('Unable to invoke pipeline without assigned core');
61 62
         }
62 63
 
63 64
         $position = $this->position++;
64
-        if (isset($this->interceptors[$position])) {
65
+        if (isset($this->interceptors[$position]))
66
+        {
65 67
             return $this->interceptors[$position]->process($controller, $action, $parameters, $this);
66 68
         }
67 69
 
Please login to merge, or discard this patch.
src/Hmvc/src/AbstractCore.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -45,9 +45,9 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function callAction(string $controller, string $action, array $parameters = [])
47 47
     {
48
-        try {
48
+        try{
49 49
             $method = new \ReflectionMethod($controller, $action);
50
-        } catch (\ReflectionException $e) {
50
+        }catch (\ReflectionException $e){
51 51
             throw new ControllerException(
52 52
                 "Invalid action `{$controller}`->`{$action}`",
53 53
                 ControllerException::BAD_ACTION,
@@ -55,22 +55,22 @@  discard block
 block discarded – undo
55 55
             );
56 56
         }
57 57
 
58
-        if ($method->isStatic() || !$method->isPublic()) {
58
+        if ($method->isStatic() || !$method->isPublic()){
59 59
             throw new ControllerException(
60 60
                 "Invalid action `{$controller}`->`{$action}`",
61 61
                 ControllerException::BAD_ACTION
62 62
             );
63 63
         }
64 64
 
65
-        try {
65
+        try{
66 66
             // getting the set of arguments should be sent to requested method
67 67
             $args = $this->resolver->resolveArguments($method, $parameters);
68
-        } catch (ArgumentException $e) {
68
+        }catch (ArgumentException $e){
69 69
             throw new ControllerException(
70 70
                 "Missing/invalid parameter '{$e->getParameter()->name}' of  `{$controller}`->`{$action}`",
71 71
                 ControllerException::BAD_ARGUMENT
72 72
             );
73
-        } catch (ContainerExceptionInterface $e) {
73
+        }catch (ContainerExceptionInterface $e){
74 74
             throw new ControllerException(
75 75
                 $e->getMessage(),
76 76
                 ControllerException::ERROR,
Please login to merge, or discard this patch.
Braces   +17 added lines, -7 removed lines patch added patch discarded remove patch
@@ -45,9 +45,12 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function callAction(string $controller, string $action, array $parameters = [])
47 47
     {
48
-        try {
48
+        try
49
+        {
49 50
             $method = new \ReflectionMethod($controller, $action);
50
-        } catch (\ReflectionException $e) {
51
+        }
52
+        catch (\ReflectionException $e)
53
+        {
51 54
             throw new ControllerException(
52 55
                 "Invalid action `{$controller}`->`{$action}`",
53 56
                 ControllerException::BAD_ACTION,
@@ -55,22 +58,28 @@  discard block
 block discarded – undo
55 58
             );
56 59
         }
57 60
 
58
-        if ($method->isStatic() || !$method->isPublic()) {
61
+        if ($method->isStatic() || !$method->isPublic())
62
+        {
59 63
             throw new ControllerException(
60 64
                 "Invalid action `{$controller}`->`{$action}`",
61 65
                 ControllerException::BAD_ACTION
62 66
             );
63 67
         }
64 68
 
65
-        try {
69
+        try
70
+        {
66 71
             // getting the set of arguments should be sent to requested method
67 72
             $args = $this->resolver->resolveArguments($method, $parameters);
68
-        } catch (ArgumentException $e) {
73
+        }
74
+        catch (ArgumentException $e)
75
+        {
69 76
             throw new ControllerException(
70 77
                 "Missing/invalid parameter '{$e->getParameter()->name}' of  `{$controller}`->`{$action}`",
71 78
                 ControllerException::BAD_ARGUMENT
72 79
             );
73
-        } catch (ContainerExceptionInterface $e) {
80
+        }
81
+        catch (ContainerExceptionInterface $e)
82
+        {
74 83
             throw new ControllerException(
75 84
                 $e->getMessage(),
76 85
                 ControllerException::ERROR,
@@ -78,7 +87,8 @@  discard block
 block discarded – undo
78 87
             );
79 88
         }
80 89
 
81
-        return ContainerScope::runScope($this->container, function () use ($controller, $method, $args) {
90
+        return ContainerScope::runScope($this->container, function () use ($controller, $method, $args)
91
+        {
82 92
             return $method->invokeArgs($this->container->get($controller), $args);
83 93
         });
84 94
     }
Please login to merge, or discard this patch.
src/Router/tests/SingleActionTest.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,9 +103,9 @@
 block discarded – undo
103 103
         $this->assertSame('echoed', (string)$response->getBody());
104 104
 
105 105
         $e = null;
106
-        try {
106
+        try{
107 107
             $router->handle(new ServerRequest([], [], new Uri('/test')));
108
-        } catch (UndefinedRouteException $e) {
108
+        }catch (UndefinedRouteException $e){
109 109
         }
110 110
 
111 111
         $this->assertNotNull($e, 'Autofill not fired');
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,9 +103,12 @@
 block discarded – undo
103 103
         $this->assertSame('echoed', (string)$response->getBody());
104 104
 
105 105
         $e = null;
106
-        try {
106
+        try
107
+        {
107 108
             $router->handle(new ServerRequest([], [], new Uri('/test')));
108
-        } catch (UndefinedRouteException $e) {
109
+        }
110
+        catch (UndefinedRouteException $e)
111
+        {
109 112
         }
110 113
 
111 114
         $this->assertNotNull($e, 'Autofill not fired');
Please login to merge, or discard this patch.