@@ -25,7 +25,7 @@ |
||
25 | 25 | */ |
26 | 26 | public function notEmpty($value, bool $asString = true): bool |
27 | 27 | { |
28 | - if ($asString && is_string($value) && trim($value) === '') { |
|
28 | + if ($asString && is_string($value) && trim($value) === ''){ |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 |
@@ -25,7 +25,8 @@ |
||
25 | 25 | */ |
26 | 26 | public function notEmpty($value, bool $asString = true): bool |
27 | 27 | { |
28 | - if ($asString && is_string($value) && trim($value) === '') { |
|
28 | + if ($asString && is_string($value) && trim($value) === '') |
|
29 | + { |
|
29 | 30 | return false; |
30 | 31 | } |
31 | 32 |
@@ -32,26 +32,26 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private function resolveFilename($file): ?string |
34 | 34 | { |
35 | - if (empty($file)) { |
|
35 | + if (empty($file)){ |
|
36 | 36 | return null; |
37 | 37 | } |
38 | 38 | |
39 | 39 | if ( |
40 | 40 | $file instanceof StreamableInterface || |
41 | 41 | ($file instanceof UploadedFileInterface && $file->getError() === 0) |
42 | - ) { |
|
42 | + ){ |
|
43 | 43 | return StreamWrapper::getFilename($file->getStream()); |
44 | 44 | } |
45 | 45 | |
46 | - if (is_array($file)) { |
|
47 | - if (!isset($file['tmp_name'])) { |
|
46 | + if (is_array($file)){ |
|
47 | + if (!isset($file['tmp_name'])){ |
|
48 | 48 | return null; |
49 | 49 | } |
50 | 50 | |
51 | 51 | $file = $file['tmp_name']; |
52 | 52 | } |
53 | 53 | |
54 | - if (!is_string($file) || !$this->files->exists($file)) { |
|
54 | + if (!is_string($file) || !$this->files->exists($file)){ |
|
55 | 55 | return null; |
56 | 56 | } |
57 | 57 | |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | */ |
67 | 67 | private function isUploaded($file): bool |
68 | 68 | { |
69 | - if (is_string($file)) { |
|
69 | + if (is_string($file)){ |
|
70 | 70 | //We can use native method |
71 | 71 | return is_uploaded_file($file); |
72 | 72 | } |
73 | 73 | |
74 | - if (is_array($file)) { |
|
74 | + if (is_array($file)){ |
|
75 | 75 | return isset($file['tmp_name']) && ( |
76 | 76 | is_uploaded_file($file['tmp_name']) || isset($file['uploaded']) |
77 | 77 | ); |
78 | 78 | } |
79 | 79 | |
80 | - if ($file instanceof UploadedFileInterface) { |
|
80 | + if ($file instanceof UploadedFileInterface){ |
|
81 | 81 | return empty($file->getError()); |
82 | 82 | } |
83 | 83 |
@@ -32,7 +32,8 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private function resolveFilename($file): ?string |
34 | 34 | { |
35 | - if (empty($file)) { |
|
35 | + if (empty($file)) |
|
36 | + { |
|
36 | 37 | return null; |
37 | 38 | } |
38 | 39 | |
@@ -43,15 +44,18 @@ discard block |
||
43 | 44 | return StreamWrapper::getFilename($file->getStream()); |
44 | 45 | } |
45 | 46 | |
46 | - if (is_array($file)) { |
|
47 | - if (!isset($file['tmp_name'])) { |
|
47 | + if (is_array($file)) |
|
48 | + { |
|
49 | + if (!isset($file['tmp_name'])) |
|
50 | + { |
|
48 | 51 | return null; |
49 | 52 | } |
50 | 53 | |
51 | 54 | $file = $file['tmp_name']; |
52 | 55 | } |
53 | 56 | |
54 | - if (!is_string($file) || !$this->files->exists($file)) { |
|
57 | + if (!is_string($file) || !$this->files->exists($file)) |
|
58 | + { |
|
55 | 59 | return null; |
56 | 60 | } |
57 | 61 | |
@@ -66,18 +70,21 @@ discard block |
||
66 | 70 | */ |
67 | 71 | private function isUploaded($file): bool |
68 | 72 | { |
69 | - if (is_string($file)) { |
|
73 | + if (is_string($file)) |
|
74 | + { |
|
70 | 75 | //We can use native method |
71 | 76 | return is_uploaded_file($file); |
72 | 77 | } |
73 | 78 | |
74 | - if (is_array($file)) { |
|
79 | + if (is_array($file)) |
|
80 | + { |
|
75 | 81 | return isset($file['tmp_name']) && ( |
76 | 82 | is_uploaded_file($file['tmp_name']) || isset($file['uploaded']) |
77 | 83 | ); |
78 | 84 | } |
79 | 85 | |
80 | - if ($file instanceof UploadedFileInterface) { |
|
86 | + if ($file instanceof UploadedFileInterface) |
|
87 | + { |
|
81 | 88 | return empty($file->getError()); |
82 | 89 | } |
83 | 90 |
@@ -51,20 +51,20 @@ |
||
51 | 51 | public function url(string $url, ?array $schemas = null, ?string $defaultSchema = null): bool |
52 | 52 | { |
53 | 53 | //Add default schema if not presented |
54 | - if (!empty($defaultSchema) && !$this->hasSchema($url)) { |
|
54 | + if (!empty($defaultSchema) && !$this->hasSchema($url)){ |
|
55 | 55 | $defaultSchema = $this->trimSchema($defaultSchema); |
56 | - if (!empty($defaultSchema)) { |
|
56 | + if (!empty($defaultSchema)){ |
|
57 | 57 | $url = "$defaultSchema://{$this->trimURL($url)}"; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | - if (empty($schemas)) { |
|
61 | + if (empty($schemas)){ |
|
62 | 62 | return (bool)filter_var($url, FILTER_VALIDATE_URL); |
63 | 63 | } |
64 | 64 | |
65 | - foreach ($schemas as $schema) { |
|
65 | + foreach ($schemas as $schema){ |
|
66 | 66 | $schema = $this->trimSchema($schema); |
67 | - if (empty($schema) || !$this->containsSchema($url, $schema)) { |
|
67 | + if (empty($schema) || !$this->containsSchema($url, $schema)){ |
|
68 | 68 | continue; |
69 | 69 | } |
70 | 70 |
@@ -51,20 +51,25 @@ |
||
51 | 51 | public function url(string $url, ?array $schemas = null, ?string $defaultSchema = null): bool |
52 | 52 | { |
53 | 53 | //Add default schema if not presented |
54 | - if (!empty($defaultSchema) && !$this->hasSchema($url)) { |
|
54 | + if (!empty($defaultSchema) && !$this->hasSchema($url)) |
|
55 | + { |
|
55 | 56 | $defaultSchema = $this->trimSchema($defaultSchema); |
56 | - if (!empty($defaultSchema)) { |
|
57 | + if (!empty($defaultSchema)) |
|
58 | + { |
|
57 | 59 | $url = "$defaultSchema://{$this->trimURL($url)}"; |
58 | 60 | } |
59 | 61 | } |
60 | 62 | |
61 | - if (empty($schemas)) { |
|
63 | + if (empty($schemas)) |
|
64 | + { |
|
62 | 65 | return (bool)filter_var($url, FILTER_VALIDATE_URL); |
63 | 66 | } |
64 | 67 | |
65 | - foreach ($schemas as $schema) { |
|
68 | + foreach ($schemas as $schema) |
|
69 | + { |
|
66 | 70 | $schema = $this->trimSchema($schema); |
67 | - if (empty($schema) || !$this->containsSchema($url, $schema)) { |
|
71 | + if (empty($schema) || !$this->containsSchema($url, $schema)) |
|
72 | + { |
|
68 | 73 | continue; |
69 | 74 | } |
70 | 75 |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function cardNumber($value): bool |
38 | 38 | { |
39 | - if (!is_string($value) || strlen($value) < 12) { |
|
39 | + if (!is_string($value) || strlen($value) < 12){ |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | - if ($value !== preg_replace('/\D+/', '', $value)) { |
|
43 | + if ($value !== preg_replace('/\D+/', '', $value)){ |
|
44 | 44 | return false; |
45 | 45 | } |
46 | 46 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $odd = strlen($value) % 2; |
49 | 49 | |
50 | 50 | $length = strlen($value); |
51 | - for ($i = 0; $i < $length; ++$i) { |
|
51 | + for ($i = 0; $i < $length; ++$i){ |
|
52 | 52 | $result += $odd |
53 | 53 | ? $value[$i] |
54 | 54 | : (($value[$i] * 2 > 9) ? $value[$i] * 2 - 9 : $value[$i] * 2); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function match($value, string $field, bool $strict = false): bool |
72 | 72 | { |
73 | - if ($strict) { |
|
73 | + if ($strict){ |
|
74 | 74 | return $value === $this->getValidator()->getValue($field, null); |
75 | 75 | } |
76 | 76 |
@@ -36,11 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function cardNumber($value): bool |
38 | 38 | { |
39 | - if (!is_string($value) || strlen($value) < 12) { |
|
39 | + if (!is_string($value) || strlen($value) < 12) |
|
40 | + { |
|
40 | 41 | return false; |
41 | 42 | } |
42 | 43 | |
43 | - if ($value !== preg_replace('/\D+/', '', $value)) { |
|
44 | + if ($value !== preg_replace('/\D+/', '', $value)) |
|
45 | + { |
|
44 | 46 | return false; |
45 | 47 | } |
46 | 48 | |
@@ -48,7 +50,8 @@ discard block |
||
48 | 50 | $odd = strlen($value) % 2; |
49 | 51 | |
50 | 52 | $length = strlen($value); |
51 | - for ($i = 0; $i < $length; ++$i) { |
|
53 | + for ($i = 0; $i < $length; ++$i) |
|
54 | + { |
|
52 | 55 | $result += $odd |
53 | 56 | ? $value[$i] |
54 | 57 | : (($value[$i] * 2 > 9) ? $value[$i] * 2 - 9 : $value[$i] * 2); |
@@ -70,7 +73,8 @@ discard block |
||
70 | 73 | */ |
71 | 74 | public function match($value, string $field, bool $strict = false): bool |
72 | 75 | { |
73 | - if ($strict) { |
|
76 | + if ($strict) |
|
77 | + { |
|
74 | 78 | return $value === $this->getValidator()->getValue($field, null); |
75 | 79 | } |
76 | 80 |
@@ -37,7 +37,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -37,7 +37,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -29,8 +29,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -29,8 +29,10 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -38,7 +38,7 @@ discard block |
||
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 |
||
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) |
@@ -66,7 +66,8 @@ |
||
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) |
@@ -27,8 +27,8 @@ |
||
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 | } |
@@ -27,8 +27,10 @@ |
||
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 | } |
@@ -32,8 +32,8 @@ |
||
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 | } |
@@ -32,8 +32,10 @@ |
||
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 | } |