@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function __construct( |
23 | 23 | private readonly FilterProviderInterface $provider, |
24 | 24 | private readonly ReaderInterface $reader |
25 | - ) { |
|
25 | + ){ |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -36,46 +36,46 @@ discard block |
||
36 | 36 | $schema = []; |
37 | 37 | $class = new \ReflectionClass($filter); |
38 | 38 | |
39 | - foreach ($class->getProperties() as $property) { |
|
40 | - foreach ($this->reader->getPropertyMetadata($property) as $attribute) { |
|
41 | - if ($attribute instanceof AbstractInput) { |
|
39 | + foreach ($class->getProperties() as $property){ |
|
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) { |
|
53 | + }catch (ValidationException $e){ |
|
54 | 54 | $errors[$prefix] = $e->errors; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $schema[$property->getName()] = $attribute->getSchema($property); |
58 | - } elseif ($attribute instanceof NestedArray) { |
|
58 | + } elseif ($attribute instanceof NestedArray){ |
|
59 | 59 | $values = $attribute->getValue($input, $property); |
60 | 60 | $propertyValues = []; |
61 | 61 | |
62 | 62 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); |
63 | 63 | |
64 | - if (\is_array($values)) { |
|
65 | - foreach (\array_keys($values) as $key) { |
|
66 | - try { |
|
64 | + if (\is_array($values)){ |
|
65 | + foreach (\array_keys($values) as $key){ |
|
66 | + try{ |
|
67 | 67 | $propertyValues[$key] = $this->provider->createFilter( |
68 | 68 | $attribute->class, |
69 | - $input->withPrefix($prefix . '.' . $key) |
|
69 | + $input->withPrefix($prefix.'.'.$key) |
|
70 | 70 | ); |
71 | - } catch (ValidationException $e) { |
|
71 | + }catch (ValidationException $e){ |
|
72 | 72 | $errors[$property->getName()][$key] = $e->errors; |
73 | 73 | } |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | $this->setValue($filter, $property, $propertyValues); |
78 | - $schema[$property->getName()] = [$attribute->class, $prefix . '.*']; |
|
78 | + $schema[$property->getName()] = [$attribute->class, $prefix.'.*']; |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | |
86 | 86 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void |
87 | 87 | { |
88 | - if ($value === null) { |
|
88 | + if ($value === null){ |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | 92 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); |
93 | 93 | |
94 | - foreach ($setters as $setter) { |
|
94 | + foreach ($setters as $setter){ |
|
95 | 95 | $value = $setter->updateValue($value); |
96 | 96 | } |
97 | 97 |
@@ -36,39 +36,54 @@ discard block |
||
36 | 36 | $schema = []; |
37 | 37 | $class = new \ReflectionClass($filter); |
38 | 38 | |
39 | - foreach ($class->getProperties() as $property) { |
|
40 | - foreach ($this->reader->getPropertyMetadata($property) as $attribute) { |
|
41 | - if ($attribute instanceof AbstractInput) { |
|
39 | + foreach ($class->getProperties() as $property) |
|
40 | + { |
|
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) { |
|
59 | + } |
|
60 | + catch (ValidationException $e) |
|
61 | + { |
|
54 | 62 | $errors[$prefix] = $e->errors; |
55 | 63 | } |
56 | 64 | |
57 | 65 | $schema[$property->getName()] = $attribute->getSchema($property); |
58 | - } elseif ($attribute instanceof NestedArray) { |
|
66 | + } |
|
67 | + elseif ($attribute instanceof NestedArray) |
|
68 | + { |
|
59 | 69 | $values = $attribute->getValue($input, $property); |
60 | 70 | $propertyValues = []; |
61 | 71 | |
62 | 72 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); |
63 | 73 | |
64 | - if (\is_array($values)) { |
|
65 | - foreach (\array_keys($values) as $key) { |
|
66 | - try { |
|
74 | + if (\is_array($values)) |
|
75 | + { |
|
76 | + foreach (\array_keys($values) as $key) |
|
77 | + { |
|
78 | + try |
|
79 | + { |
|
67 | 80 | $propertyValues[$key] = $this->provider->createFilter( |
68 | 81 | $attribute->class, |
69 | 82 | $input->withPrefix($prefix . '.' . $key) |
70 | 83 | ); |
71 | - } catch (ValidationException $e) { |
|
84 | + } |
|
85 | + catch (ValidationException $e) |
|
86 | + { |
|
72 | 87 | $errors[$property->getName()][$key] = $e->errors; |
73 | 88 | } |
74 | 89 | } |
@@ -85,13 +100,15 @@ discard block |
||
85 | 100 | |
86 | 101 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void |
87 | 102 | { |
88 | - if ($value === null) { |
|
103 | + if ($value === null) |
|
104 | + { |
|
89 | 105 | return; |
90 | 106 | } |
91 | 107 | |
92 | 108 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); |
93 | 109 | |
94 | - foreach ($setters as $setter) { |
|
110 | + foreach ($setters as $setter) |
|
111 | + { |
|
95 | 112 | $value = $setter->updateValue($value); |
96 | 113 | } |
97 | 114 |