Passed
Pull Request — master (#1016)
by Maxim
11:07 queued 01:04
created
src/Filters/src/Attribute/CastingErrorMessage.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@
 block discarded – undo
15 15
     public function __construct(
16 16
         protected ?string $message = null,
17 17
         ?callable $callback = null
18
-    ) {
19
-        if ($callback !== null) {
18
+    ){
19
+        if ($callback !== null){
20 20
             $this->callback = $callback(...);
21 21
         }
22 22
     }
23 23
 
24 24
     public function getMessage(SetterException $exception, mixed $value = null): ?string
25 25
     {
26
-        if ($this->callback instanceof \Closure) {
26
+        if ($this->callback instanceof \Closure){
27 27
             return ($this->callback)($exception, $value);
28 28
         }
29 29
 
Please login to merge, or discard this patch.
src/Filters/src/Exception/SetterException.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@
 block discarded – undo
9 9
     public function __construct(\Throwable $previous = null, ?string $message = null)
10 10
     {
11 11
         parent::__construct(
12
-            message: $message ?? 'Unable to set value. The given data was invalid.',
13
-            previous: $previous,
12
+            message : $message ?? 'Unable to set value. The given data was invalid.',
13
+            previous : $previous,
14 14
         );
15 15
     }
16 16
 }
Please login to merge, or discard this patch.
src/Filters/src/Model/Mapper/EnumCaster.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@
 block discarded – undo
26 26
          */
27 27
         $enum = $type->getName();
28 28
 
29
-        try {
29
+        try{
30 30
             $property->setValue($filter, $value instanceof $enum ? $value : $enum::from($value));
31
-        } catch (\Throwable $e) {
31
+        }catch (\Throwable $e){
32 32
             throw new SetterException(
33 33
                 previous: $e,
34 34
                 message: \sprintf('Unable to set enum value. %s', $e->getMessage()),
Please login to merge, or discard this patch.
src/Filters/src/Model/Mapper/DefaultCaster.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
 
17 17
     public function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
18 18
     {
19
-        try {
19
+        try{
20 20
             $property->setValue($filter, $value);
21
-        } catch (\Throwable $e) {
21
+        }catch (\Throwable $e){
22 22
             throw new SetterException(
23 23
                 previous: $e,
24 24
                 message: \sprintf('Unable to set value. %s', $e->getMessage()),
Please login to merge, or discard this patch.
src/Filters/src/Model/Mapper/UuidCaster.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function supports(\ReflectionNamedType $type): bool
17 17
     {
18
-        if ($this->interfaceExists === null) {
18
+        if ($this->interfaceExists === null){
19 19
             $this->interfaceExists = \interface_exists(UuidInterface::class);
20 20
         }
21 21
 
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 
25 25
     public function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
26 26
     {
27
-        try {
27
+        try{
28 28
             $property->setValue($filter, $value instanceof UuidInterface ? $value : Uuid::fromString($value));
29
-        } catch (\Throwable $e) {
29
+        }catch (\Throwable $e){
30 30
             throw new SetterException(
31 31
                 previous: $e,
32 32
                 message: \sprintf('Unable to set UUID value. %s', $e->getMessage()),
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
 
37 37
     private function implements(string $haystack, string $interface): bool
38 38
     {
39
-        if ($haystack === $interface) {
39
+        if ($haystack === $interface){
40 40
             return true;
41 41
         }
42 42
 
43
-        foreach ((array)\class_implements($haystack) as $implements) {
44
-            if ($implements === $interface) {
43
+        foreach ((array)\class_implements($haystack) as $implements){
44
+            if ($implements === $interface){
45 45
                 return true;
46 46
             }
47 47
 
48
-            if (self::implements($implements, $interface)) {
48
+            if (self::implements($implements, $interface)){
49 49
                 return true;
50 50
             }
51 51
         }
Please login to merge, or discard this patch.
src/Filters/src/Model/Schema/AttributeMapper.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
         private readonly FilterProviderInterface $provider,
27 27
         private readonly ReaderInterface $reader,
28 28
         private readonly Mapper $mapper
29
-    ) {
29
+    ){
30 30
     }
31 31
 
32 32
     /**
@@ -40,54 +40,54 @@  discard block
 block discarded – undo
40 40
         $optionalFilters = [];
41 41
         $class = new \ReflectionClass($filter);
42 42
 
43
-        foreach ($class->getProperties() as $property) {
43
+        foreach ($class->getProperties() as $property){
44 44
             /** @var object $attribute */
45
-            foreach ($this->reader->getPropertyMetadata($property) as $attribute) {
46
-                if ($attribute instanceof AbstractInput) {
45
+            foreach ($this->reader->getPropertyMetadata($property) as $attribute){
46
+                if ($attribute instanceof AbstractInput){
47 47
                     $value = $attribute->getValue($input, $property);
48
-                    try {
48
+                    try{
49 49
                         $this->setValue($filter, $property, $value);
50
-                    } catch (SetterException $e) {
50
+                    }catch (SetterException $e){
51 51
                         $errors[$property->getName()] = $this->createErrorMessage($e, $property, $value);
52 52
                     }
53 53
                     $schema[$property->getName()] = $attribute->getSchema($property);
54
-                } elseif ($attribute instanceof NestedFilter) {
54
+                } elseif ($attribute instanceof NestedFilter){
55 55
                     $prefix = $attribute->prefix ?? $property->name;
56
-                    try {
56
+                    try{
57 57
                         $value = $this->provider->createFilter(
58 58
                             $attribute->class,
59 59
                             $input->withPrefix($prefix)
60 60
                         );
61 61
 
62
-                        try {
62
+                        try{
63 63
                             $this->setValue($filter, $property, $value);
64
-                        } catch (SetterException $e) {
64
+                        }catch (SetterException $e){
65 65
                             $errors[$property->getName()] = $this->createErrorMessage($e, $property, $value);
66 66
                         }
67
-                    } catch (ValidationException $e) {
68
-                        if ($this->allowsNull($property)) {
67
+                    }catch (ValidationException $e){
68
+                        if ($this->allowsNull($property)){
69 69
                             $this->setValue($filter, $property, null);
70 70
                             $optionalFilters[] = $property->getName();
71
-                        } else {
71
+                        }else{
72 72
                             $errors[$prefix] = $e->errors;
73 73
                         }
74 74
                     }
75 75
 
76 76
                     $schema[$property->getName()] = $attribute->getSchema($property);
77
-                } elseif ($attribute instanceof NestedArray) {
77
+                } elseif ($attribute instanceof NestedArray){
78 78
                     $values = $attribute->getValue($input, $property);
79 79
                     $propertyValues = [];
80 80
 
81 81
                     $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName();
82 82
 
83
-                    if (\is_array($values)) {
84
-                        foreach (\array_keys($values) as $key) {
85
-                            try {
83
+                    if (\is_array($values)){
84
+                        foreach (\array_keys($values) as $key){
85
+                            try{
86 86
                                 $propertyValues[$key] = $this->provider->createFilter(
87 87
                                     $attribute->class,
88
-                                    $input->withPrefix($prefix . '.' . $key)
88
+                                    $input->withPrefix($prefix.'.'.$key)
89 89
                                 );
90
-                            } catch (ValidationException $e) {
90
+                            }catch (ValidationException $e){
91 91
                                 /** @psalm-suppress InvalidArrayOffset */
92 92
                                 $errors[$property->getName()][$key] = $e->errors;
93 93
                             }
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
                     }
96 96
 
97 97
                     $this->setValue($filter, $property, $propertyValues);
98
-                    $schema[$property->getName()] = [$attribute->class, $prefix . '.*'];
99
-                } elseif ($attribute instanceof Setter) {
98
+                    $schema[$property->getName()] = [$attribute->class, $prefix.'.*'];
99
+                } elseif ($attribute instanceof Setter){
100 100
                     $setters[$property->getName()][] = $attribute;
101 101
                 }
102 102
             }
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 
108 108
     private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void
109 109
     {
110
-        if ($value === null) {
110
+        if ($value === null){
111 111
             return;
112 112
         }
113 113
 
114 114
         $setters = $this->reader->getPropertyMetadata($property, Setter::class);
115 115
 
116
-        foreach ($setters as $setter) {
116
+        foreach ($setters as $setter){
117 117
             $value = $setter->updateValue($value);
118 118
         }
119 119
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
     ): string {
135 135
         $attribute = $this->reader->firstPropertyMetadata($property, CastingErrorMessage::class);
136 136
 
137
-        if ($attribute === null) {
137
+        if ($attribute === null){
138 138
             return $exception->getMessage();
139 139
         }
140 140
 
Please login to merge, or discard this patch.