Passed
Push — master ( 2291e3...cd7158 )
by Anton
03:34
created
src/Validation/src/Config/ValidatorConfig.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
     public function __construct(array $config = [])
38 38
     {
39 39
         parent::__construct($config);
40
-        if (!empty($this->config['aliases'])) {
40
+        if (!empty($this->config['aliases'])){
41 41
             $this->config['aliases'] = $this->normalizeAliases($this->config['aliases']);
42 42
         }
43 43
     }
@@ -59,12 +59,12 @@  discard block
 block discarded – undo
59 59
      */
60 60
     public function getChecker(string $name): Autowire
61 61
     {
62
-        if (!$this->hasChecker($name)) {
62
+        if (!$this->hasChecker($name)){
63 63
             throw new ValidationException("Undefined checker `{$name}``.");
64 64
         }
65 65
 
66 66
         $instance = $this->wire('checkers', $name);
67
-        if ($instance !== null) {
67
+        if ($instance !== null){
68 68
             return $instance;
69 69
         }
70 70
 
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
      */
87 87
     public function getCondition(string $name): Autowire
88 88
     {
89
-        if (!$this->hasCondition($name)) {
89
+        if (!$this->hasCondition($name)){
90 90
             throw new ValidationException("Undefined condition `{$name}`.");
91 91
         }
92 92
 
93 93
         $instance = $this->wire('conditions', $name);
94
-        if ($instance !== null) {
94
+        if ($instance !== null){
95 95
             return $instance;
96 96
         }
97 97
 
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function mapFunction($function)
109 109
     {
110
-        if (is_string($function)) {
110
+        if (is_string($function)){
111 111
             $function = $this->resolveAlias($function);
112
-            if (strpos($function, ':') !== false) {
112
+            if (strpos($function, ':') !== false){
113 113
                 $function = explode(':', $function);
114 114
             }
115 115
         }
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function wire(string $section, string $name): ?Autowire
126 126
     {
127
-        if (is_string($this->config[$section][$name])) {
127
+        if (is_string($this->config[$section][$name])){
128 128
             return new Autowire($this->config[$section][$name]);
129 129
         }
130 130
 
131
-        if (isset($this->config[$section][$name]['class'])) {
131
+        if (isset($this->config[$section][$name]['class'])){
132 132
             return new Autowire(
133 133
                 $this->config[$section][$name]['class'],
134 134
                 $this->config[$section][$name]['options'] ?? []
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     private function normalizeAliases(array $aliases): array
148 148
     {
149
-        return array_map(static function ($value) {
149
+        return array_map(static function ($value){
150 150
             return str_replace('::', ':', $value);
151 151
         }, $aliases);
152 152
     }
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@  discard block
 block discarded – undo
37 37
     public function __construct(array $config = [])
38 38
     {
39 39
         parent::__construct($config);
40
-        if (!empty($this->config['aliases'])) {
40
+        if (!empty($this->config['aliases']))
41
+        {
41 42
             $this->config['aliases'] = $this->normalizeAliases($this->config['aliases']);
42 43
         }
43 44
     }
@@ -59,12 +60,14 @@  discard block
 block discarded – undo
59 60
      */
60 61
     public function getChecker(string $name): Autowire
61 62
     {
62
-        if (!$this->hasChecker($name)) {
63
+        if (!$this->hasChecker($name))
64
+        {
63 65
             throw new ValidationException("Undefined checker `{$name}``.");
64 66
         }
65 67
 
66 68
         $instance = $this->wire('checkers', $name);
67
-        if ($instance !== null) {
69
+        if ($instance !== null)
70
+        {
68 71
             return $instance;
69 72
         }
70 73
 
@@ -86,12 +89,14 @@  discard block
 block discarded – undo
86 89
      */
87 90
     public function getCondition(string $name): Autowire
88 91
     {
89
-        if (!$this->hasCondition($name)) {
92
+        if (!$this->hasCondition($name))
93
+        {
90 94
             throw new ValidationException("Undefined condition `{$name}`.");
91 95
         }
92 96
 
93 97
         $instance = $this->wire('conditions', $name);
94
-        if ($instance !== null) {
98
+        if ($instance !== null)
99
+        {
95 100
             return $instance;
96 101
         }
97 102
 
@@ -107,9 +112,11 @@  discard block
 block discarded – undo
107 112
      */
108 113
     public function mapFunction($function)
109 114
     {
110
-        if (is_string($function)) {
115
+        if (is_string($function))
116
+        {
111 117
             $function = $this->resolveAlias($function);
112
-            if (strpos($function, ':') !== false) {
118
+            if (strpos($function, ':') !== false)
119
+            {
113 120
                 $function = explode(':', $function);
114 121
             }
115 122
         }
@@ -124,11 +131,13 @@  discard block
 block discarded – undo
124 131
      */
125 132
     private function wire(string $section, string $name): ?Autowire
126 133
     {
127
-        if (is_string($this->config[$section][$name])) {
134
+        if (is_string($this->config[$section][$name]))
135
+        {
128 136
             return new Autowire($this->config[$section][$name]);
129 137
         }
130 138
 
131
-        if (isset($this->config[$section][$name]['class'])) {
139
+        if (isset($this->config[$section][$name]['class']))
140
+        {
132 141
             return new Autowire(
133 142
                 $this->config[$section][$name]['class'],
134 143
                 $this->config[$section][$name]['options'] ?? []
@@ -146,7 +155,8 @@  discard block
 block discarded – undo
146 155
      */
147 156
     private function normalizeAliases(array $aliases): array
148 157
     {
149
-        return array_map(static function ($value) {
158
+        return array_map(static function ($value)
159
+        {
150 160
             return str_replace('::', ':', $value);
151 161
         }, $aliases);
152 162
     }
Please login to merge, or discard this patch.
src/Validation/src/RuleParser.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $rules = is_array($rules) ? $rules : [$rules];
31 31
 
32
-        foreach ($rules as $rule) {
33
-            if ($rule instanceof \Closure) {
32
+        foreach ($rules as $rule){
33
+            if ($rule instanceof \Closure){
34 34
                 yield null => $rule;
35 35
                 continue;
36 36
             }
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
      */
45 45
     public function parseCheck($chunk)
46 46
     {
47
-        if (is_string($chunk)) {
47
+        if (is_string($chunk)){
48 48
             $function = str_replace('::', ':', $chunk);
49
-        } else {
50
-            if (!is_array($chunk) || !isset($chunk[0])) {
49
+        }else{
50
+            if (!is_array($chunk) || !isset($chunk[0])){
51 51
                 throw new ParserException('Validation rule does not define any check.');
52 52
             }
53 53
 
54 54
             $function = $chunk[0];
55 55
         }
56 56
 
57
-        if (is_string($function)) {
57
+        if (is_string($function)){
58 58
             return str_replace('::', ':', $function);
59 59
         }
60 60
 
@@ -66,18 +66,18 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function parseArgs($chunk): array
68 68
     {
69
-        if (!is_array($chunk)) {
69
+        if (!is_array($chunk)){
70 70
             return [];
71 71
         }
72 72
 
73
-        foreach (self::ARGUMENTS as $index) {
74
-            if (isset($chunk[$index])) {
73
+        foreach (self::ARGUMENTS as $index){
74
+            if (isset($chunk[$index])){
75 75
                 return $chunk[$index];
76 76
             }
77 77
         }
78 78
 
79 79
         unset($chunk[0]);
80
-        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index) {
80
+        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index){
81 81
             unset($chunk[$index]);
82 82
         }
83 83
 
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function parseMessage($chunk): ?string
91 91
     {
92
-        if (!is_array($chunk)) {
92
+        if (!is_array($chunk)){
93 93
             return null;
94 94
         }
95 95
 
96
-        foreach (self::MESSAGES as $index) {
97
-            if (isset($chunk[$index])) {
96
+        foreach (self::MESSAGES as $index){
97
+            if (isset($chunk[$index])){
98 98
                 return $chunk[$index];
99 99
             }
100 100
         }
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
      */
108 108
     public function parseConditions($chunk): array
109 109
     {
110
-        foreach (self::CONDITIONS as $index) {
111
-            if (isset($chunk[$index])) {
110
+        foreach (self::CONDITIONS as $index){
111
+            if (isset($chunk[$index])){
112 112
                 $conditions = [];
113
-                foreach ((array)$chunk[$index] as $key => $value) {
114
-                    if (is_numeric($key)) {
113
+                foreach ((array)$chunk[$index] as $key => $value){
114
+                    if (is_numeric($key)){
115 115
                         $conditions[$value] = [];
116
-                    } else {
116
+                    }else{
117 117
                         $conditions[$key] = (array)$value;
118 118
                     }
119 119
                 }
Please login to merge, or discard this patch.
Braces   +38 added lines, -18 removed lines patch added patch discarded remove patch
@@ -29,8 +29,10 @@  discard block
 block discarded – undo
29 29
     {
30 30
         $rules = is_array($rules) ? $rules : [$rules];
31 31
 
32
-        foreach ($rules as $rule) {
33
-            if ($rule instanceof \Closure) {
32
+        foreach ($rules as $rule)
33
+        {
34
+            if ($rule instanceof \Closure)
35
+            {
34 36
                 yield null => $rule;
35 37
                 continue;
36 38
             }
@@ -44,17 +46,22 @@  discard block
 block discarded – undo
44 46
      */
45 47
     public function parseCheck($chunk)
46 48
     {
47
-        if (is_string($chunk)) {
49
+        if (is_string($chunk))
50
+        {
48 51
             $function = str_replace('::', ':', $chunk);
49
-        } else {
50
-            if (!is_array($chunk) || !isset($chunk[0])) {
52
+        }
53
+        else
54
+        {
55
+            if (!is_array($chunk) || !isset($chunk[0]))
56
+            {
51 57
                 throw new ParserException('Validation rule does not define any check.');
52 58
             }
53 59
 
54 60
             $function = $chunk[0];
55 61
         }
56 62
 
57
-        if (is_string($function)) {
63
+        if (is_string($function))
64
+        {
58 65
             return str_replace('::', ':', $function);
59 66
         }
60 67
 
@@ -66,18 +73,22 @@  discard block
 block discarded – undo
66 73
      */
67 74
     public function parseArgs($chunk): array
68 75
     {
69
-        if (!is_array($chunk)) {
76
+        if (!is_array($chunk))
77
+        {
70 78
             return [];
71 79
         }
72 80
 
73
-        foreach (self::ARGUMENTS as $index) {
74
-            if (isset($chunk[$index])) {
81
+        foreach (self::ARGUMENTS as $index)
82
+        {
83
+            if (isset($chunk[$index]))
84
+            {
75 85
                 return $chunk[$index];
76 86
             }
77 87
         }
78 88
 
79 89
         unset($chunk[0]);
80
-        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index) {
90
+        foreach (array_merge(self::MESSAGES, self::CONDITIONS) as $index)
91
+        {
81 92
             unset($chunk[$index]);
82 93
         }
83 94
 
@@ -89,12 +100,15 @@  discard block
 block discarded – undo
89 100
      */
90 101
     public function parseMessage($chunk): ?string
91 102
     {
92
-        if (!is_array($chunk)) {
103
+        if (!is_array($chunk))
104
+        {
93 105
             return null;
94 106
         }
95 107
 
96
-        foreach (self::MESSAGES as $index) {
97
-            if (isset($chunk[$index])) {
108
+        foreach (self::MESSAGES as $index)
109
+        {
110
+            if (isset($chunk[$index]))
111
+            {
98 112
                 return $chunk[$index];
99 113
             }
100 114
         }
@@ -107,13 +121,19 @@  discard block
 block discarded – undo
107 121
      */
108 122
     public function parseConditions($chunk): array
109 123
     {
110
-        foreach (self::CONDITIONS as $index) {
111
-            if (isset($chunk[$index])) {
124
+        foreach (self::CONDITIONS as $index)
125
+        {
126
+            if (isset($chunk[$index]))
127
+            {
112 128
                 $conditions = [];
113
-                foreach ((array)$chunk[$index] as $key => $value) {
114
-                    if (is_numeric($key)) {
129
+                foreach ((array)$chunk[$index] as $key => $value)
130
+                {
131
+                    if (is_numeric($key))
132
+                    {
115 133
                         $conditions[$value] = [];
116
-                    } else {
134
+                    }
135
+                    else
136
+                    {
117 137
                         $conditions[$key] = (array)$value;
118 138
                     }
119 139
                 }
Please login to merge, or discard this patch.
src/Validation/src/CheckerRule.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
         string $method,
39 39
         array $args = [],
40 40
         ?string $message = null
41
-    ) {
41
+    ){
42 42
         $this->checker = $checker;
43 43
         $this->method = $method;
44 44
         $this->args = $args;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      */
67 67
     public function getMessage(string $field, $value): string
68 68
     {
69
-        if (!empty($this->message)) {
69
+        if (!empty($this->message)){
70 70
             return Translator::interpolate(
71 71
                 $this->message,
72 72
                 array_merge([$value, $field], $this->args)
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,7 +66,8 @@
 block discarded – undo
66 66
      */
67 67
     public function getMessage(string $field, $value): string
68 68
     {
69
-        if (!empty($this->message)) {
69
+        if (!empty($this->message))
70
+        {
70 71
             return Translator::interpolate(
71 72
                 $this->message,
72 73
                 array_merge([$value, $field], $this->args)
Please login to merge, or discard this patch.
src/Validation/src/Condition/WithoutAnyCondition.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (empty($validator->getValue($option))) {
30
+        foreach ($this->options as $option){
31
+            if (empty($validator->getValue($option))){
32 32
                 return true;
33 33
             }
34 34
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,10 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (empty($validator->getValue($option))) {
30
+        foreach ($this->options as $option)
31
+        {
32
+            if (empty($validator->getValue($option)))
33
+            {
32 34
                 return true;
33 35
             }
34 36
         }
Please login to merge, or discard this patch.
src/Validation/src/Condition/NoneOfCondition.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@
 block discarded – undo
32 32
      */
33 33
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
34 34
     {
35
-        foreach ($this->compositor->makeConditions($field, $this->options) as $condition) {
36
-            if ($condition->isMet($validator, $field, $value)) {
35
+        foreach ($this->compositor->makeConditions($field, $this->options) as $condition){
36
+            if ($condition->isMet($validator, $field, $value)){
37 37
                 return false;
38 38
             }
39 39
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,8 +32,10 @@
 block discarded – undo
32 32
      */
33 33
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
34 34
     {
35
-        foreach ($this->compositor->makeConditions($field, $this->options) as $condition) {
36
-            if ($condition->isMet($validator, $field, $value)) {
35
+        foreach ($this->compositor->makeConditions($field, $this->options) as $condition)
36
+        {
37
+            if ($condition->isMet($validator, $field, $value))
38
+            {
37 39
                 return false;
38 40
             }
39 41
         }
Please login to merge, or discard this patch.
src/Validation/src/Condition/WithoutAllCondition.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (!empty($validator->getValue($option))) {
30
+        foreach ($this->options as $option){
31
+            if (!empty($validator->getValue($option))){
32 32
                 return false;
33 33
             }
34 34
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,10 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (!empty($validator->getValue($option))) {
30
+        foreach ($this->options as $option)
31
+        {
32
+            if (!empty($validator->getValue($option)))
33
+            {
32 34
                 return false;
33 35
             }
34 36
         }
Please login to merge, or discard this patch.
src/Validation/src/Condition/WithAllCondition.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (empty($validator->getValue($option))) {
30
+        foreach ($this->options as $option){
31
+            if (empty($validator->getValue($option))){
32 32
                 return false;
33 33
             }
34 34
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,10 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (empty($validator->getValue($option))) {
30
+        foreach ($this->options as $option)
31
+        {
32
+            if (empty($validator->getValue($option)))
33
+            {
32 34
                 return false;
33 35
             }
34 36
         }
Please login to merge, or discard this patch.
src/Validation/src/Condition/PresentCondition.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (!$validator->hasValue($option)) {
30
+        foreach ($this->options as $option){
31
+            if (!$validator->hasValue($option)){
32 32
                 return false;
33 33
             }
34 34
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,8 +27,10 @@
 block discarded – undo
27 27
      */
28 28
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
29 29
     {
30
-        foreach ($this->options as $option) {
31
-            if (!$validator->hasValue($option)) {
30
+        foreach ($this->options as $option)
31
+        {
32
+            if (!$validator->hasValue($option))
33
+            {
32 34
                 return false;
33 35
             }
34 36
         }
Please login to merge, or discard this patch.
src/Validation/src/Condition/AnyOfCondition.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,12 +32,12 @@
 block discarded – undo
32 32
      */
33 33
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
34 34
     {
35
-        if (empty($this->options)) {
35
+        if (empty($this->options)){
36 36
             return true;
37 37
         }
38 38
 
39
-        foreach ($this->compositor->makeConditions($field, $this->options) as $condition) {
40
-            if ($condition->isMet($validator, $field, $value)) {
39
+        foreach ($this->compositor->makeConditions($field, $this->options) as $condition){
40
+            if ($condition->isMet($validator, $field, $value)){
41 41
                 return true;
42 42
             }
43 43
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,12 +32,15 @@
 block discarded – undo
32 32
      */
33 33
     public function isMet(ValidatorInterface $validator, string $field, $value): bool
34 34
     {
35
-        if (empty($this->options)) {
35
+        if (empty($this->options))
36
+        {
36 37
             return true;
37 38
         }
38 39
 
39
-        foreach ($this->compositor->makeConditions($field, $this->options) as $condition) {
40
-            if ($condition->isMet($validator, $field, $value)) {
40
+        foreach ($this->compositor->makeConditions($field, $this->options) as $condition)
41
+        {
42
+            if ($condition->isMet($validator, $field, $value))
43
+            {
41 44
                 return true;
42 45
             }
43 46
         }
Please login to merge, or discard this patch.