@@ -33,11 +33,11 @@ |
||
33 | 33 | { |
34 | 34 | $declaration = $this->createDeclaration(FilterDeclaration::class); |
35 | 35 | |
36 | - foreach ($this->properties as $property) { |
|
36 | + foreach ($this->properties as $property){ |
|
37 | 37 | $declaration->addProperty($property); |
38 | 38 | } |
39 | 39 | |
40 | - if ($this->useValidator) { |
|
40 | + if ($this->useValidator){ |
|
41 | 41 | $declaration->addFilterDefinition(); |
42 | 42 | } |
43 | 43 |
@@ -33,11 +33,13 @@ |
||
33 | 33 | { |
34 | 34 | $declaration = $this->createDeclaration(FilterDeclaration::class); |
35 | 35 | |
36 | - foreach ($this->properties as $property) { |
|
36 | + foreach ($this->properties as $property) |
|
37 | + { |
|
37 | 38 | $declaration->addProperty($property); |
38 | 39 | } |
39 | 40 | |
40 | - if ($this->useValidator) { |
|
41 | + if ($this->useValidator) |
|
42 | + { |
|
41 | 43 | $declaration->addFilterDefinition(); |
42 | 44 | } |
43 | 45 |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | string $name, |
27 | 27 | ?string $comment = null, |
28 | 28 | ?string $namespace = null, |
29 | - ) { |
|
29 | + ){ |
|
30 | 30 | parent::__construct($config, $name, $comment, $namespace); |
31 | 31 | } |
32 | 32 | |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | public function addFilterDefinition(): void |
42 | 42 | { |
43 | 43 | $validation = $this->validationConfig->getDefaultValidator(); |
44 | - if ($validation === null) { |
|
44 | + if ($validation === null){ |
|
45 | 45 | throw new ValidationException( |
46 | 46 | 'Default Validator is not configured. Read more at https://spiral.dev/docs/validation-factory' |
47 | 47 | ); |
48 | 48 | } |
49 | 49 | |
50 | - if (!\class_exists($validation)) { |
|
50 | + if (!\class_exists($validation)){ |
|
51 | 51 | throw new ValidationException( |
52 | 52 | \sprintf( |
53 | 53 | 'Default Validator "%s" is not class or does not exist.', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $p = $this->class->addProperty($property->getName()) |
82 | 82 | ->setType($property->getType()); |
83 | 83 | |
84 | - foreach ($property->getAttributes() as $attribute) { |
|
84 | + foreach ($property->getAttributes() as $attribute){ |
|
85 | 85 | $p->addAttribute($attribute->getName(), $attribute->getArguments()); |
86 | 86 | } |
87 | 87 | } |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | { |
91 | 91 | $declaredType = null; |
92 | 92 | |
93 | - if (\str_contains($property, ':')) { |
|
93 | + if (\str_contains($property, ':')){ |
|
94 | 94 | $segments = \explode(':', $property, 3); |
95 | 95 | |
96 | - if (\count($segments) === 3) { |
|
96 | + if (\count($segments) === 3){ |
|
97 | 97 | [$property, $source, $declaredType] = $segments; |
98 | - } else { |
|
98 | + }else{ |
|
99 | 99 | [$property, $source] = $segments; |
100 | 100 | } |
101 | 101 | } |
@@ -41,13 +41,15 @@ discard block |
||
41 | 41 | public function addFilterDefinition(): void |
42 | 42 | { |
43 | 43 | $validation = $this->validationConfig->getDefaultValidator(); |
44 | - if ($validation === null) { |
|
44 | + if ($validation === null) |
|
45 | + { |
|
45 | 46 | throw new ValidationException( |
46 | 47 | 'Default Validator is not configured. Read more at https://spiral.dev/docs/validation-factory' |
47 | 48 | ); |
48 | 49 | } |
49 | 50 | |
50 | - if (!\class_exists($validation)) { |
|
51 | + if (!\class_exists($validation)) |
|
52 | + { |
|
51 | 53 | throw new ValidationException( |
52 | 54 | \sprintf( |
53 | 55 | 'Default Validator "%s" is not class or does not exist.', |
@@ -81,7 +83,8 @@ discard block |
||
81 | 83 | $p = $this->class->addProperty($property->getName()) |
82 | 84 | ->setType($property->getType()); |
83 | 85 | |
84 | - foreach ($property->getAttributes() as $attribute) { |
|
86 | + foreach ($property->getAttributes() as $attribute) |
|
87 | + { |
|
85 | 88 | $p->addAttribute($attribute->getName(), $attribute->getArguments()); |
86 | 89 | } |
87 | 90 | } |
@@ -90,12 +93,16 @@ discard block |
||
90 | 93 | { |
91 | 94 | $declaredType = null; |
92 | 95 | |
93 | - if (\str_contains($property, ':')) { |
|
96 | + if (\str_contains($property, ':')) |
|
97 | + { |
|
94 | 98 | $segments = \explode(':', $property, 3); |
95 | 99 | |
96 | - if (\count($segments) === 3) { |
|
100 | + if (\count($segments) === 3) |
|
101 | + { |
|
97 | 102 | [$property, $source, $declaredType] = $segments; |
98 | - } else { |
|
103 | + } |
|
104 | + else |
|
105 | + { |
|
99 | 106 | [$property, $source] = $segments; |
100 | 107 | } |
101 | 108 | } |
@@ -70,7 +70,7 @@ |
||
70 | 70 | return new $validationClass(validationRules: [ |
71 | 71 | // Put your validation rules here |
72 | 72 | ]); |
73 | -PHP, |
|
73 | +php, |
|
74 | 74 | ); |
75 | 75 | } |
76 | 76 |
@@ -20,7 +20,7 @@ |
||
20 | 20 | string $name, |
21 | 21 | ?string $comment = null, |
22 | 22 | ?string $namespace = null, |
23 | - ) { |
|
23 | + ){ |
|
24 | 24 | $this->namespace = new PhpNamespace($namespace ?? $this->config->classNamespace(static::TYPE, $name)); |
25 | 25 | |
26 | 26 | $this->class = $this->namespace |