Passed
Pull Request — master (#961)
by Maxim
09:18
created
src/Filters/src/Model/Mapper/SetterRegistry.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
     public function __construct(array $setters = [])
13 13
     {
14
-        foreach ($setters as $setter) {
14
+        foreach ($setters as $setter){
15 15
             $this->register($setter);
16 16
         }
17 17
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,8 @@
 block discarded – undo
11 11
 
12 12
     public function __construct(array $setters = [])
13 13
     {
14
-        foreach ($setters as $setter) {
14
+        foreach ($setters as $setter)
15
+        {
15 16
             $this->register($setter);
16 17
         }
17 18
     }
Please login to merge, or discard this patch.
src/Filters/src/Model/Mapper/Uuid.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function supports(\ReflectionNamedType $type): bool
15 15
     {
16
-        if ($this->interfaceExists === null) {
16
+        if ($this->interfaceExists === null){
17 17
             $this->interfaceExists = \interface_exists(UuidInterface::class);
18 18
         }
19 19
 
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 
28 28
     private function implements(string $haystack, string $interface): bool
29 29
     {
30
-        if ($haystack === $interface) {
30
+        if ($haystack === $interface){
31 31
             return true;
32 32
         }
33 33
 
34
-        foreach ((array)\class_implements($haystack) as $implements) {
35
-            if ($implements === $interface) {
34
+        foreach ((array)\class_implements($haystack) as $implements){
35
+            if ($implements === $interface){
36 36
                 return true;
37 37
             }
38 38
 
39
-            if (self::implements($implements, $interface)) {
39
+            if (self::implements($implements, $interface)){
40 40
                 return true;
41 41
             }
42 42
         }
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function supports(\ReflectionNamedType $type): bool
15 15
     {
16
-        if ($this->interfaceExists === null) {
16
+        if ($this->interfaceExists === null)
17
+        {
17 18
             $this->interfaceExists = \interface_exists(UuidInterface::class);
18 19
         }
19 20
 
@@ -27,16 +28,20 @@  discard block
 block discarded – undo
27 28
 
28 29
     private function implements(string $haystack, string $interface): bool
29 30
     {
30
-        if ($haystack === $interface) {
31
+        if ($haystack === $interface)
32
+        {
31 33
             return true;
32 34
         }
33 35
 
34
-        foreach ((array)\class_implements($haystack) as $implements) {
35
-            if ($implements === $interface) {
36
+        foreach ((array)\class_implements($haystack) as $implements)
37
+        {
38
+            if ($implements === $interface)
39
+            {
36 40
                 return true;
37 41
             }
38 42
 
39
-            if (self::implements($implements, $interface)) {
43
+            if (self::implements($implements, $interface))
44
+            {
40 45
                 return true;
41 46
             }
42 47
         }
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/Builder.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function makeSchema(string $name, array $schema): array
44 44
     {
45
-        if (empty($schema)) {
45
+        if (empty($schema)){
46 46
             throw new SchemaException(\sprintf('Filter `%s` does not define any schema', $name));
47 47
         }
48 48
 
49 49
         $result = [];
50
-        foreach ($schema as $field => $definition) {
50
+        foreach ($schema as $field => $definition){
51 51
             $optional = false;
52 52
 
53 53
             // short definition
54
-            if (\is_string($definition)) {
54
+            if (\is_string($definition)){
55 55
                 // simple scalar field definition
56
-                if (!\class_exists($definition)) {
56
+                if (!\class_exists($definition)){
57 57
                     [$source, $origin] = $this->parseDefinition($field, $definition);
58 58
                     $result[$field] = [
59 59
                         self::SCHEMA_SOURCE => $source,
@@ -74,25 +74,25 @@  discard block
 block discarded – undo
74 74
                 continue;
75 75
             }
76 76
 
77
-            if (!\is_array($definition) || $definition === []) {
77
+            if (!\is_array($definition) || $definition === []){
78 78
                 throw new SchemaException(
79 79
                     \sprintf('Invalid schema definition at `%s`->`%s`', $name, $field)
80 80
                 );
81 81
             }
82 82
 
83 83
             // complex definition
84
-            if (!empty($definition[self::ORIGIN])) {
84
+            if (!empty($definition[self::ORIGIN])){
85 85
                 $origin = $definition[self::ORIGIN];
86 86
 
87 87
                 // [class, 'data:something.*'] vs [class, 'data:something']
88 88
                 $iterate = \str_contains((string)$origin, '.*') || !empty($definition[self::ITERATE]);
89 89
                 $origin = \rtrim($origin, '.*');
90
-            } else {
90
+            }else{
91 91
                 $origin = $field;
92 92
                 $iterate = true;
93 93
             }
94 94
 
95
-            if (!empty($definition[self::OPTIONAL])) {
95
+            if (!empty($definition[self::OPTIONAL])){
96 96
                 $optional = true;
97 97
             }
98 98
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 self::SCHEMA_OPTIONAL => $optional,
106 106
             ];
107 107
 
108
-            if ($iterate) {
108
+            if ($iterate){
109 109
                 [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin);
110 110
 
111 111
                 $map[self::SCHEMA_ITERATE_SOURCE] = $source;
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
             'path',
138 138
             'remoteAddress',
139 139
             'uri',
140
-        ], true)) {
140
+        ], true)){
141 141
             return [$definition, $field];
142 142
         }
143 143
 
144
-        if (!\str_contains($definition, ':')) {
144
+        if (!\str_contains($definition, ':')){
145 145
             return ['data', empty($definition) ? $field : $definition];
146 146
         }
147 147
 
Please login to merge, or discard this patch.
Braces   +23 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,18 +42,22 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function makeSchema(string $name, array $schema): array
44 44
     {
45
-        if (empty($schema)) {
45
+        if (empty($schema))
46
+        {
46 47
             throw new SchemaException(\sprintf('Filter `%s` does not define any schema', $name));
47 48
         }
48 49
 
49 50
         $result = [];
50
-        foreach ($schema as $field => $definition) {
51
+        foreach ($schema as $field => $definition)
52
+        {
51 53
             $optional = false;
52 54
 
53 55
             // short definition
54
-            if (\is_string($definition)) {
56
+            if (\is_string($definition))
57
+            {
55 58
                 // simple scalar field definition
56
-                if (!\class_exists($definition)) {
59
+                if (!\class_exists($definition))
60
+                {
57 61
                     [$source, $origin] = $this->parseDefinition($field, $definition);
58 62
                     $result[$field] = [
59 63
                         self::SCHEMA_SOURCE => $source,
@@ -74,25 +78,30 @@  discard block
 block discarded – undo
74 78
                 continue;
75 79
             }
76 80
 
77
-            if (!\is_array($definition) || $definition === []) {
81
+            if (!\is_array($definition) || $definition === [])
82
+            {
78 83
                 throw new SchemaException(
79 84
                     \sprintf('Invalid schema definition at `%s`->`%s`', $name, $field)
80 85
                 );
81 86
             }
82 87
 
83 88
             // complex definition
84
-            if (!empty($definition[self::ORIGIN])) {
89
+            if (!empty($definition[self::ORIGIN]))
90
+            {
85 91
                 $origin = $definition[self::ORIGIN];
86 92
 
87 93
                 // [class, 'data:something.*'] vs [class, 'data:something']
88 94
                 $iterate = \str_contains((string)$origin, '.*') || !empty($definition[self::ITERATE]);
89 95
                 $origin = \rtrim($origin, '.*');
90
-            } else {
96
+            }
97
+            else
98
+            {
91 99
                 $origin = $field;
92 100
                 $iterate = true;
93 101
             }
94 102
 
95
-            if (!empty($definition[self::OPTIONAL])) {
103
+            if (!empty($definition[self::OPTIONAL]))
104
+            {
96 105
                 $optional = true;
97 106
             }
98 107
 
@@ -105,7 +114,8 @@  discard block
 block discarded – undo
105 114
                 self::SCHEMA_OPTIONAL => $optional,
106 115
             ];
107 116
 
108
-            if ($iterate) {
117
+            if ($iterate)
118
+            {
109 119
                 [$source, $origin] = $this->parseDefinition($field, $definition[self::ITERATE] ?? $origin);
110 120
 
111 121
                 $map[self::SCHEMA_ITERATE_SOURCE] = $source;
@@ -137,11 +147,13 @@  discard block
 block discarded – undo
137 147
             'path',
138 148
             'remoteAddress',
139 149
             'uri',
140
-        ], true)) {
150
+        ], true))
151
+        {
141 152
             return [$definition, $field];
142 153
         }
143 154
 
144
-        if (!\str_contains($definition, ':')) {
155
+        if (!\str_contains($definition, ':'))
156
+        {
145 157
             return ['data', empty($definition) ? $field : $definition];
146 158
         }
147 159
 
Please login to merge, or discard this patch.
src/Framework/Bootloader/Security/FiltersBootloader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         private readonly ContainerInterface $container,
44 44
         private readonly BinderInterface $binder,
45 45
         private readonly ConfiguratorInterface $config
46
-    ) {
46
+    ){
47 47
     }
48 48
 
49 49
     /**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         ?EventDispatcherInterface $dispatcher = null
94 94
     ): FilterProvider {
95 95
         $core = new InterceptableCore(new Core(), $dispatcher);
96
-        foreach ($config->getInterceptors() as $interceptor) {
96
+        foreach ($config->getInterceptors() as $interceptor){
97 97
             $core->addInterceptor($container->get($interceptor));
98 98
         }
99 99
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -93,7 +93,8 @@
 block discarded – undo
93 93
         ?EventDispatcherInterface $dispatcher = null
94 94
     ): FilterProvider {
95 95
         $core = new InterceptableCore(new Core(), $dispatcher);
96
-        foreach ($config->getInterceptors() as $interceptor) {
96
+        foreach ($config->getInterceptors() as $interceptor)
97
+        {
97 98
             $core->addInterceptor($container->get($interceptor));
98 99
         }
99 100
 
Please login to merge, or discard this patch.
src/Filters/src/Model/FilterProvider.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         private readonly ContainerInterface $container,
24 24
         private readonly ResolverInterface $resolver,
25 25
         private readonly CoreInterface $core
26
-    ) {
26
+    ){
27 27
     }
28 28
 
29 29
     public function createFilter(string $name, InputInterface $input): FilterInterface
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $filter = $this->createFilterInstance($name);
35 35
         [$mappingSchema, $errors, $setters, $optionalFilters] = $attributeMapper->map($filter, $input);
36 36
 
37
-        if ($filter instanceof HasFilterDefinition) {
37
+        if ($filter instanceof HasFilterDefinition){
38 38
             $mappingSchema = \array_merge(
39 39
                 $mappingSchema,
40 40
                 $filter->filterDefinition()->mappingSchema()
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         \assert($schemaBuilder instanceof Builder);
49 49
 
50 50
         $schema = $schemaBuilder->makeSchema($name, $mappingSchema);
51
-        foreach ($optionalFilters as $optionalFilter) {
51
+        foreach ($optionalFilters as $optionalFilter){
52 52
             $schema[$optionalFilter][Builder::SCHEMA_OPTIONAL] = true;
53 53
         }
54 54
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $class = new \ReflectionClass($name);
67 67
 
68 68
         $args = [];
69
-        if ($constructor = $class->getConstructor()) {
69
+        if ($constructor = $class->getConstructor()){
70 70
             $args = $this->resolver->resolveArguments($constructor);
71 71
         }
72 72
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -34,7 +34,8 @@  discard block
 block discarded – undo
34 34
         $filter = $this->createFilterInstance($name);
35 35
         [$mappingSchema, $errors, $setters, $optionalFilters] = $attributeMapper->map($filter, $input);
36 36
 
37
-        if ($filter instanceof HasFilterDefinition) {
37
+        if ($filter instanceof HasFilterDefinition)
38
+        {
38 39
             $mappingSchema = \array_merge(
39 40
                 $mappingSchema,
40 41
                 $filter->filterDefinition()->mappingSchema()
@@ -48,7 +49,8 @@  discard block
 block discarded – undo
48 49
         \assert($schemaBuilder instanceof Builder);
49 50
 
50 51
         $schema = $schemaBuilder->makeSchema($name, $mappingSchema);
51
-        foreach ($optionalFilters as $optionalFilter) {
52
+        foreach ($optionalFilters as $optionalFilter)
53
+        {
52 54
             $schema[$optionalFilter][Builder::SCHEMA_OPTIONAL] = true;
53 55
         }
54 56
 
@@ -66,7 +68,8 @@  discard block
 block discarded – undo
66 68
         $class = new \ReflectionClass($name);
67 69
 
68 70
         $args = [];
69
-        if ($constructor = $class->getConstructor()) {
71
+        if ($constructor = $class->getConstructor())
72
+        {
70 73
             $args = $this->resolver->resolveArguments($constructor);
71 74
         }
72 75
 
Please login to merge, or discard this patch.
src/Filters/src/Model/Mapper/Mapper.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function __construct(
15 15
         private readonly SetterRegistryInterface $registry
16
-    ) {
16
+    ){
17 17
     }
18 18
 
19 19
     /**
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     public function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
23 23
     {
24 24
         $type = $property->getType();
25
-        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
26
-            foreach ($this->registry->getSetters() as $setter) {
27
-                if ($setter->supports($type)) {
25
+        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()){
26
+            foreach ($this->registry->getSetters() as $setter){
27
+                if ($setter->supports($type)){
28 28
                     $setter->setValue($filter, $property, $value);
29 29
                     return;
30 30
                 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,12 @@
 block discarded – undo
22 22
     public function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
23 23
     {
24 24
         $type = $property->getType();
25
-        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
26
-            foreach ($this->registry->getSetters() as $setter) {
27
-                if ($setter->supports($type)) {
25
+        if ($type instanceof \ReflectionNamedType && !$type->isBuiltin())
26
+        {
27
+            foreach ($this->registry->getSetters() as $setter)
28
+            {
29
+                if ($setter->supports($type))
30
+                {
28 31
                     $setter->setValue($filter, $property, $value);
29 32
                     return;
30 33
                 }
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/AttributeMapper.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
         private readonly FilterProviderInterface $provider,
22 22
         private readonly ReaderInterface $reader,
23 23
         private readonly Mapper $mapper
24
-    ) {
24
+    ){
25 25
     }
26 26
 
27 27
     /**
@@ -35,53 +35,53 @@  discard block
 block discarded – undo
35 35
         $optionalFilters = [];
36 36
         $class = new \ReflectionClass($filter);
37 37
 
38
-        foreach ($class->getProperties() as $property) {
38
+        foreach ($class->getProperties() as $property){
39 39
             /** @var object $attribute */
40
-            foreach ($this->reader->getPropertyMetadata($property) as $attribute) {
41
-                if ($attribute instanceof AbstractInput) {
40
+            foreach ($this->reader->getPropertyMetadata($property) as $attribute){
41
+                if ($attribute instanceof AbstractInput){
42 42
                     $this->setValue($filter, $property, $attribute->getValue($input, $property));
43 43
                     $schema[$property->getName()] = $attribute->getSchema($property);
44
-                } elseif ($attribute instanceof NestedFilter) {
44
+                } elseif ($attribute instanceof NestedFilter){
45 45
                     $prefix = $attribute->prefix ?? $property->name;
46
-                    try {
46
+                    try{
47 47
                         $value = $this->provider->createFilter(
48 48
                             $attribute->class,
49 49
                             $input->withPrefix($prefix)
50 50
                         );
51 51
 
52 52
                         $this->setValue($filter, $property, $value);
53
-                    } catch (ValidationException $e) {
54
-                        if ($this->allowsNull($property)) {
53
+                    }catch (ValidationException $e){
54
+                        if ($this->allowsNull($property)){
55 55
                             $this->setValue($filter, $property, null);
56 56
                             $optionalFilters[] = $property->getName();
57
-                        } else {
57
+                        }else{
58 58
                             $errors[$prefix] = $e->errors;
59 59
                         }
60 60
                     }
61 61
 
62 62
                     $schema[$property->getName()] = $attribute->getSchema($property);
63
-                } elseif ($attribute instanceof NestedArray) {
63
+                } elseif ($attribute instanceof NestedArray){
64 64
                     $values = $attribute->getValue($input, $property);
65 65
                     $propertyValues = [];
66 66
 
67 67
                     $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName();
68 68
 
69
-                    if (\is_array($values)) {
70
-                        foreach (\array_keys($values) as $key) {
71
-                            try {
69
+                    if (\is_array($values)){
70
+                        foreach (\array_keys($values) as $key){
71
+                            try{
72 72
                                 $propertyValues[$key] = $this->provider->createFilter(
73 73
                                     $attribute->class,
74
-                                    $input->withPrefix($prefix . '.' . $key)
74
+                                    $input->withPrefix($prefix.'.'.$key)
75 75
                                 );
76
-                            } catch (ValidationException $e) {
76
+                            }catch (ValidationException $e){
77 77
                                 $errors[$property->getName()][$key] = $e->errors;
78 78
                             }
79 79
                         }
80 80
                     }
81 81
 
82 82
                     $this->setValue($filter, $property, $propertyValues);
83
-                    $schema[$property->getName()] = [$attribute->class, $prefix . '.*'];
84
-                } elseif ($attribute instanceof Setter) {
83
+                    $schema[$property->getName()] = [$attribute->class, $prefix.'.*'];
84
+                } elseif ($attribute instanceof Setter){
85 85
                     $setters[$property->getName()][] = $attribute;
86 86
                 }
87 87
             }
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 
93 93
     private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
94 94
     {
95
-        if ($value === null) {
95
+        if ($value === null){
96 96
             return;
97 97
         }
98 98
 
99 99
         $setters = $this->reader->getPropertyMetadata($property, Setter::class);
100 100
 
101
-        foreach ($setters as $setter) {
101
+        foreach ($setters as $setter){
102 102
             $value = $setter->updateValue($value);
103 103
         }
104 104
 
Please login to merge, or discard this patch.
Braces   +38 added lines, -16 removed lines patch added patch discarded remove patch
@@ -35,45 +35,63 @@  discard block
 block discarded – undo
35 35
         $optionalFilters = [];
36 36
         $class = new \ReflectionClass($filter);
37 37
 
38
-        foreach ($class->getProperties() as $property) {
38
+        foreach ($class->getProperties() as $property)
39
+        {
39 40
             /** @var object $attribute */
40
-            foreach ($this->reader->getPropertyMetadata($property) as $attribute) {
41
-                if ($attribute instanceof AbstractInput) {
41
+            foreach ($this->reader->getPropertyMetadata($property) as $attribute)
42
+            {
43
+                if ($attribute instanceof AbstractInput)
44
+                {
42 45
                     $this->setValue($filter, $property, $attribute->getValue($input, $property));
43 46
                     $schema[$property->getName()] = $attribute->getSchema($property);
44
-                } elseif ($attribute instanceof NestedFilter) {
47
+                }
48
+                elseif ($attribute instanceof NestedFilter)
49
+                {
45 50
                     $prefix = $attribute->prefix ?? $property->name;
46
-                    try {
51
+                    try
52
+                    {
47 53
                         $value = $this->provider->createFilter(
48 54
                             $attribute->class,
49 55
                             $input->withPrefix($prefix)
50 56
                         );
51 57
 
52 58
                         $this->setValue($filter, $property, $value);
53
-                    } catch (ValidationException $e) {
54
-                        if ($this->allowsNull($property)) {
59
+                    }
60
+                    catch (ValidationException $e)
61
+                    {
62
+                        if ($this->allowsNull($property))
63
+                        {
55 64
                             $this->setValue($filter, $property, null);
56 65
                             $optionalFilters[] = $property->getName();
57
-                        } else {
66
+                        }
67
+                        else
68
+                        {
58 69
                             $errors[$prefix] = $e->errors;
59 70
                         }
60 71
                     }
61 72
 
62 73
                     $schema[$property->getName()] = $attribute->getSchema($property);
63
-                } elseif ($attribute instanceof NestedArray) {
74
+                }
75
+                elseif ($attribute instanceof NestedArray)
76
+                {
64 77
                     $values = $attribute->getValue($input, $property);
65 78
                     $propertyValues = [];
66 79
 
67 80
                     $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName();
68 81
 
69
-                    if (\is_array($values)) {
70
-                        foreach (\array_keys($values) as $key) {
71
-                            try {
82
+                    if (\is_array($values))
83
+                    {
84
+                        foreach (\array_keys($values) as $key)
85
+                        {
86
+                            try
87
+                            {
72 88
                                 $propertyValues[$key] = $this->provider->createFilter(
73 89
                                     $attribute->class,
74 90
                                     $input->withPrefix($prefix . '.' . $key)
75 91
                                 );
76
-                            } catch (ValidationException $e) {
92
+                            }
93
+                            catch (ValidationException $e)
94
+                            {
77 95
                                 $errors[$property->getName()][$key] = $e->errors;
78 96
                             }
79 97
                         }
@@ -81,7 +99,9 @@  discard block
 block discarded – undo
81 99
 
82 100
                     $this->setValue($filter, $property, $propertyValues);
83 101
                     $schema[$property->getName()] = [$attribute->class, $prefix . '.*'];
84
-                } elseif ($attribute instanceof Setter) {
102
+                }
103
+                elseif ($attribute instanceof Setter)
104
+                {
85 105
                     $setters[$property->getName()][] = $attribute;
86 106
                 }
87 107
             }
@@ -92,13 +112,15 @@  discard block
 block discarded – undo
92 112
 
93 113
     private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
94 114
     {
95
-        if ($value === null) {
115
+        if ($value === null)
116
+        {
96 117
             return;
97 118
         }
98 119
 
99 120
         $setters = $this->reader->getPropertyMetadata($property, Setter::class);
100 121
 
101
-        foreach ($setters as $setter) {
122
+        foreach ($setters as $setter)
123
+        {
102 124
             $value = $setter->updateValue($value);
103 125
         }
104 126
 
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/InputMapper.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 {
14 14
     public function __construct(
15 15
         private readonly FilterProviderInterface $provider
16
-    ) {
16
+    ){
17 17
     }
18 18
 
19 19
     public function map(array $mappingSchema, InputInterface $input, array $setters = []): array
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
         $errors = [];
22 22
         $result = [];
23 23
 
24
-        foreach ($mappingSchema as $field => $map) {
25
-            if (empty($map[Builder::SCHEMA_FILTER])) {
24
+        foreach ($mappingSchema as $field => $map){
25
+            if (empty($map[Builder::SCHEMA_FILTER])){
26 26
                 $value = $input->getValue($map[Builder::SCHEMA_SOURCE], $map[Builder::SCHEMA_ORIGIN]);
27 27
 
28
-                if ($value !== null) {
28
+                if ($value !== null){
29 29
                     /** @var Setter $setter */
30
-                    foreach ($setters[$field] ?? [] as $setter) {
30
+                    foreach ($setters[$field] ?? [] as $setter){
31 31
                         $value = $setter->updateValue($value);
32 32
                     }
33 33
 
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
             }
38 38
 
39 39
             $nested = $map[Builder::SCHEMA_FILTER];
40
-            if (empty($map[Builder::SCHEMA_ARRAY])) {
40
+            if (empty($map[Builder::SCHEMA_ARRAY])){
41 41
                 // slicing down
42
-                try {
42
+                try{
43 43
                     $result[$field] = $this->provider->createFilter($nested, $input->withPrefix($map[Builder::SCHEMA_ORIGIN]));
44
-                } catch (ValidationException $e) {
45
-                    if ($map[Builder::SCHEMA_OPTIONAL]) {
44
+                }catch (ValidationException $e){
45
+                    if ($map[Builder::SCHEMA_OPTIONAL]){
46 46
                         $result[$field] = null;
47 47
                         continue;
48 48
                     }
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
             $values = [];
55 55
 
56 56
             // List of "key" => "location in request"
57
-            foreach ($this->iterate($map, $input) as $index => $origin) {
58
-                try {
57
+            foreach ($this->iterate($map, $input) as $index => $origin){
58
+                try{
59 59
                     $values[$index] = $this->provider->createFilter($nested, $input->withPrefix($origin));
60
-                } catch (ValidationException $e) {
60
+                }catch (ValidationException $e){
61 61
                     $errors[$field][$index] = $e->errors;
62 62
                 }
63 63
             }
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
             $schema[Builder::SCHEMA_ITERATE_ORIGIN]
79 79
         );
80 80
 
81
-        if (empty($values) || !\is_array($values)) {
81
+        if (empty($values) || !\is_array($values)){
82 82
             return [];
83 83
         }
84 84
 
85
-        foreach (\array_keys($values) as $key) {
86
-            yield $key => $schema[Builder::SCHEMA_ORIGIN] . '.' . $key;
85
+        foreach (\array_keys($values) as $key){
86
+            yield $key => $schema[Builder::SCHEMA_ORIGIN].'.'.$key;
87 87
         }
88 88
     }
89 89
 }
Please login to merge, or discard this patch.
Braces   +28 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,13 +21,17 @@  discard block
 block discarded – undo
21 21
         $errors = [];
22 22
         $result = [];
23 23
 
24
-        foreach ($mappingSchema as $field => $map) {
25
-            if (empty($map[Builder::SCHEMA_FILTER])) {
24
+        foreach ($mappingSchema as $field => $map)
25
+        {
26
+            if (empty($map[Builder::SCHEMA_FILTER]))
27
+            {
26 28
                 $value = $input->getValue($map[Builder::SCHEMA_SOURCE], $map[Builder::SCHEMA_ORIGIN]);
27 29
 
28
-                if ($value !== null) {
30
+                if ($value !== null)
31
+                {
29 32
                     /** @var Setter $setter */
30
-                    foreach ($setters[$field] ?? [] as $setter) {
33
+                    foreach ($setters[$field] ?? [] as $setter)
34
+                    {
31 35
                         $value = $setter->updateValue($value);
32 36
                     }
33 37
 
@@ -37,12 +41,17 @@  discard block
 block discarded – undo
37 41
             }
38 42
 
39 43
             $nested = $map[Builder::SCHEMA_FILTER];
40
-            if (empty($map[Builder::SCHEMA_ARRAY])) {
44
+            if (empty($map[Builder::SCHEMA_ARRAY]))
45
+            {
41 46
                 // slicing down
42
-                try {
47
+                try
48
+                {
43 49
                     $result[$field] = $this->provider->createFilter($nested, $input->withPrefix($map[Builder::SCHEMA_ORIGIN]));
44
-                } catch (ValidationException $e) {
45
-                    if ($map[Builder::SCHEMA_OPTIONAL]) {
50
+                }
51
+                catch (ValidationException $e)
52
+                {
53
+                    if ($map[Builder::SCHEMA_OPTIONAL])
54
+                    {
46 55
                         $result[$field] = null;
47 56
                         continue;
48 57
                     }
@@ -54,10 +63,14 @@  discard block
 block discarded – undo
54 63
             $values = [];
55 64
 
56 65
             // List of "key" => "location in request"
57
-            foreach ($this->iterate($map, $input) as $index => $origin) {
58
-                try {
66
+            foreach ($this->iterate($map, $input) as $index => $origin)
67
+            {
68
+                try
69
+                {
59 70
                     $values[$index] = $this->provider->createFilter($nested, $input->withPrefix($origin));
60
-                } catch (ValidationException $e) {
71
+                }
72
+                catch (ValidationException $e)
73
+                {
61 74
                     $errors[$field][$index] = $e->errors;
62 75
                 }
63 76
             }
@@ -78,11 +91,13 @@  discard block
 block discarded – undo
78 91
             $schema[Builder::SCHEMA_ITERATE_ORIGIN]
79 92
         );
80 93
 
81
-        if (empty($values) || !\is_array($values)) {
94
+        if (empty($values) || !\is_array($values))
95
+        {
82 96
             return [];
83 97
         }
84 98
 
85
-        foreach (\array_keys($values) as $key) {
99
+        foreach (\array_keys($values) as $key)
100
+        {
86 101
             yield $key => $schema[Builder::SCHEMA_ORIGIN] . '.' . $key;
87 102
         }
88 103
     }
Please login to merge, or discard this patch.