@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | private readonly ContainerInterface $container, |
| 25 | 25 | private readonly ResolverInterface $resolver, |
| 26 | 26 | private readonly CoreInterface $core |
| 27 | - ) { |
|
| 27 | + ){ |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public function createFilter(string $name, InputInterface $input): FilterInterface |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $filter = $this->createFilterInstance($name); |
| 36 | 36 | [$mappingSchema, $errors, $setters] = $attributeMapper->map($filter, $input); |
| 37 | 37 | |
| 38 | - if ($filter instanceof HasFilterDefinition) { |
|
| 38 | + if ($filter instanceof HasFilterDefinition){ |
|
| 39 | 39 | $mappingSchema = \array_merge( |
| 40 | 40 | $mappingSchema, |
| 41 | 41 | $filter->filterDefinition()->mappingSchema() |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $class = new \ReflectionClass($name); |
| 65 | 65 | |
| 66 | 66 | $args = []; |
| 67 | - if ($constructor = $class->getConstructor()) { |
|
| 67 | + if ($constructor = $class->getConstructor()){ |
|
| 68 | 68 | $args = $this->resolver->resolveArguments($constructor); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -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 | /** |
@@ -37,47 +37,47 @@ discard block |
||
| 37 | 37 | $setters = []; |
| 38 | 38 | $class = new \ReflectionClass($filter); |
| 39 | 39 | |
| 40 | - foreach ($class->getProperties() as $property) { |
|
| 41 | - foreach ($this->reader->getPropertyMetadata($property) as $attribute) { |
|
| 42 | - if ($attribute instanceof AbstractInput) { |
|
| 40 | + foreach ($class->getProperties() as $property){ |
|
| 41 | + foreach ($this->reader->getPropertyMetadata($property) as $attribute){ |
|
| 42 | + if ($attribute instanceof AbstractInput){ |
|
| 43 | 43 | $this->setValue($filter, $property, $attribute->getValue($input, $property)); |
| 44 | 44 | $schema[$property->getName()] = $attribute->getSchema($property); |
| 45 | - } elseif ($attribute instanceof NestedFilter) { |
|
| 45 | + } elseif ($attribute instanceof NestedFilter){ |
|
| 46 | 46 | $prefix = $attribute->prefix ?? $property->name; |
| 47 | - try { |
|
| 47 | + try{ |
|
| 48 | 48 | $value = $this->provider->createFilter( |
| 49 | 49 | $attribute->class, |
| 50 | 50 | $input->withPrefix($prefix) |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | 53 | $this->setValue($filter, $property, $value); |
| 54 | - } catch (ValidationException $e) { |
|
| 54 | + }catch (ValidationException $e){ |
|
| 55 | 55 | $errors[$prefix] = $e->errors; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $schema[$property->getName()] = $attribute->getSchema($property); |
| 59 | - } elseif ($attribute instanceof NestedArray) { |
|
| 59 | + } elseif ($attribute instanceof NestedArray){ |
|
| 60 | 60 | $values = $attribute->getValue($input, $property); |
| 61 | 61 | $propertyValues = []; |
| 62 | 62 | |
| 63 | 63 | $prefix = $attribute->input->key ?? $attribute->prefix ?? $property->getName(); |
| 64 | 64 | |
| 65 | - if (\is_array($values)) { |
|
| 66 | - foreach (\array_keys($values) as $key) { |
|
| 67 | - try { |
|
| 65 | + if (\is_array($values)){ |
|
| 66 | + foreach (\array_keys($values) as $key){ |
|
| 67 | + try{ |
|
| 68 | 68 | $propertyValues[$key] = $this->provider->createFilter( |
| 69 | 69 | $attribute->class, |
| 70 | - $input->withPrefix($prefix . '.' . $key) |
|
| 70 | + $input->withPrefix($prefix.'.'.$key) |
|
| 71 | 71 | ); |
| 72 | - } catch (ValidationException $e) { |
|
| 72 | + }catch (ValidationException $e){ |
|
| 73 | 73 | $errors[$property->getName()][$key] = $e->errors; |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | $this->setValue($filter, $property, $propertyValues); |
| 79 | - $schema[$property->getName()] = [$attribute->class, $prefix . '.*']; |
|
| 80 | - } elseif ($attribute instanceof Setter) { |
|
| 79 | + $schema[$property->getName()] = [$attribute->class, $prefix.'.*']; |
|
| 80 | + } elseif ($attribute instanceof Setter){ |
|
| 81 | 81 | $setters[$property->getName()][] = $attribute; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | private function setValue(FilterInterface $filter, \ReflectionProperty $property, mixed $value): void |
| 90 | 90 | { |
| 91 | - if ($value === null) { |
|
| 91 | + if ($value === null){ |
|
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $setters = $this->reader->getPropertyMetadata($property, Setter::class); |
| 96 | 96 | |
| 97 | - foreach ($setters as $setter) { |
|
| 97 | + foreach ($setters as $setter){ |
|
| 98 | 98 | $value = $setter->updateValue($value); |
| 99 | 99 | } |
| 100 | 100 | |
@@ -13,7 +13,7 @@ discard block |
||
| 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 |
||
| 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,11 +37,11 @@ discard block |
||
| 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) { |
|
| 44 | + }catch (ValidationException $e){ |
|
| 45 | 45 | $errors[$field] = $e->errors; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | $values = []; |
| 52 | 52 | |
| 53 | 53 | // List of "key" => "location in request" |
| 54 | - foreach ($this->iterate($map, $input) as $index => $origin) { |
|
| 55 | - try { |
|
| 54 | + foreach ($this->iterate($map, $input) as $index => $origin){ |
|
| 55 | + try{ |
|
| 56 | 56 | $values[$index] = $this->provider->createFilter($nested, $input->withPrefix($origin)); |
| 57 | - } catch (ValidationException $e) { |
|
| 57 | + }catch (ValidationException $e){ |
|
| 58 | 58 | $errors[$field][$index] = $e->errors; |
| 59 | 59 | } |
| 60 | 60 | } |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | $schema[Builder::SCHEMA_ITERATE_ORIGIN] |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - if (empty($values) || !\is_array($values)) { |
|
| 78 | + if (empty($values) || !\is_array($values)){ |
|
| 79 | 79 | return []; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - foreach (\array_keys($values) as $key) { |
|
| 83 | - yield $key => $schema[Builder::SCHEMA_ORIGIN] . '.' . $key; |
|
| 82 | + foreach (\array_keys($values) as $key){ |
|
| 83 | + yield $key => $schema[Builder::SCHEMA_ORIGIN].'.'.$key; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |