@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getMessage(string $field, $value): string |
75 | 75 | { |
76 | - if (!empty($this->message)) { |
|
76 | + if (!empty($this->message)){ |
|
77 | 77 | return Translator::interpolate( |
78 | 78 | $this->message, |
79 | 79 | array_merge([$value, $field], $this->args) |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | } |
82 | 82 | |
83 | 83 | $name = $this->check; |
84 | - if (is_array($name) && isset($name[0], $name[1])) { |
|
84 | + if (is_array($name) && isset($name[0], $name[1])){ |
|
85 | 85 | $name = sprintf( |
86 | 86 | '%s::%s', |
87 | 87 | is_object($name[0]) ? get_class($name[0]) : $name, |
88 | 88 | $name[1] |
89 | 89 | ); |
90 | - } elseif (!is_string($name)) { |
|
90 | + } elseif (!is_string($name)){ |
|
91 | 91 | $name = '~user-defined~'; |
92 | 92 | } |
93 | 93 |
@@ -73,7 +73,8 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function getMessage(string $field, $value): string |
75 | 75 | { |
76 | - if (!empty($this->message)) { |
|
76 | + if (!empty($this->message)) |
|
77 | + { |
|
77 | 78 | return Translator::interpolate( |
78 | 79 | $this->message, |
79 | 80 | array_merge([$value, $field], $this->args) |
@@ -81,13 +82,16 @@ discard block |
||
81 | 82 | } |
82 | 83 | |
83 | 84 | $name = $this->check; |
84 | - if (is_array($name) && isset($name[0], $name[1])) { |
|
85 | + if (is_array($name) && isset($name[0], $name[1])) |
|
86 | + { |
|
85 | 87 | $name = sprintf( |
86 | 88 | '%s::%s', |
87 | 89 | is_object($name[0]) ? get_class($name[0]) : $name, |
88 | 90 | $name[1] |
89 | 91 | ); |
90 | - } elseif (!is_string($name)) { |
|
92 | + } |
|
93 | + elseif (!is_string($name)) |
|
94 | + { |
|
91 | 95 | $name = '~user-defined~'; |
92 | 96 | } |
93 | 97 |
@@ -40,11 +40,11 @@ |
||
40 | 40 | */ |
41 | 41 | public function getConditions(): \Generator |
42 | 42 | { |
43 | - if (empty($this->conditions)) { |
|
43 | + if (empty($this->conditions)){ |
|
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
47 | - foreach ($this->conditions as $condition) { |
|
47 | + foreach ($this->conditions as $condition){ |
|
48 | 48 | yield $condition->withOptions($this->conditions->offsetGet($condition)); |
49 | 49 | } |
50 | 50 | } |
@@ -40,11 +40,13 @@ |
||
40 | 40 | */ |
41 | 41 | public function getConditions(): \Generator |
42 | 42 | { |
43 | - if (empty($this->conditions)) { |
|
43 | + if (empty($this->conditions)) |
|
44 | + { |
|
44 | 45 | return; |
45 | 46 | } |
46 | 47 | |
47 | - foreach ($this->conditions as $condition) { |
|
48 | + foreach ($this->conditions as $condition) |
|
49 | + { |
|
48 | 50 | yield $condition->withOptions($this->conditions->offsetGet($condition)); |
49 | 51 | } |
50 | 52 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ValidatorConfig $config, |
42 | 42 | ParserInterface $parser = null, |
43 | 43 | FactoryInterface $factory = null |
44 | - ) { |
|
44 | + ){ |
|
45 | 45 | $this->config = $config; |
46 | 46 | $this->parser = $parser ?? new RuleParser(); |
47 | 47 | $this->factory = $factory ?? new Container(); |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getRules($rules): \Generator |
80 | 80 | { |
81 | - foreach ($this->parser->split($rules) as $id => $rule) { |
|
82 | - if (empty($id) || $rule instanceof \Closure) { |
|
81 | + foreach ($this->parser->split($rules) as $id => $rule){ |
|
82 | + if (empty($id) || $rule instanceof \Closure){ |
|
83 | 83 | yield new CallableRule($rule); |
84 | 84 | continue; |
85 | 85 | } |
86 | 86 | |
87 | 87 | // fetch from cache |
88 | - if (isset($this->rules[$id])) { |
|
88 | + if (isset($this->rules[$id])){ |
|
89 | 89 | yield $this->rules[$id]; |
90 | 90 | continue; |
91 | 91 | } |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | $args = $this->parser->parseArgs($rule); |
127 | 127 | $message = $this->parser->parseMessage($rule); |
128 | 128 | |
129 | - if (!is_array($check)) { |
|
129 | + if (!is_array($check)){ |
|
130 | 130 | return new CallableRule($check, $args, $message); |
131 | 131 | } |
132 | 132 | |
133 | - if (is_string($check[0]) && $this->config->hasChecker($check[0])) { |
|
133 | + if (is_string($check[0]) && $this->config->hasChecker($check[0])){ |
|
134 | 134 | $check[0] = $this->config->getChecker($check[0])->resolve($this->factory); |
135 | 135 | |
136 | 136 | return new CheckerRule($check[0], $check[1], $args, $message); |
137 | 137 | } |
138 | 138 | |
139 | - if (!is_object($check[0])) { |
|
139 | + if (!is_object($check[0])){ |
|
140 | 140 | $check[0] = (new Autowire($check[0]))->resolve($this->factory); |
141 | 141 | } |
142 | 142 | |
@@ -151,17 +151,17 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function makeConditions(array $conditions): ?\SplObjectStorage |
153 | 153 | { |
154 | - if (empty($conditions)) { |
|
154 | + if (empty($conditions)){ |
|
155 | 155 | return null; |
156 | 156 | } |
157 | 157 | |
158 | 158 | $storage = new \SplObjectStorage(); |
159 | - foreach ($conditions as $condition => $options) { |
|
159 | + foreach ($conditions as $condition => $options){ |
|
160 | 160 | $condition = $this->config->resolveAlias($condition); |
161 | 161 | |
162 | - if ($this->config->hasCondition($condition)) { |
|
162 | + if ($this->config->hasCondition($condition)){ |
|
163 | 163 | $autowire = $this->config->getCondition($condition); |
164 | - } else { |
|
164 | + }else{ |
|
165 | 165 | $autowire = new Autowire($condition); |
166 | 166 | } |
167 | 167 |
@@ -78,14 +78,17 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function getRules($rules): \Generator |
80 | 80 | { |
81 | - foreach ($this->parser->split($rules) as $id => $rule) { |
|
82 | - if (empty($id) || $rule instanceof \Closure) { |
|
81 | + foreach ($this->parser->split($rules) as $id => $rule) |
|
82 | + { |
|
83 | + if (empty($id) || $rule instanceof \Closure) |
|
84 | + { |
|
83 | 85 | yield new CallableRule($rule); |
84 | 86 | continue; |
85 | 87 | } |
86 | 88 | |
87 | 89 | // fetch from cache |
88 | - if (isset($this->rules[$id])) { |
|
90 | + if (isset($this->rules[$id])) |
|
91 | + { |
|
89 | 92 | yield $this->rules[$id]; |
90 | 93 | continue; |
91 | 94 | } |
@@ -126,17 +129,20 @@ discard block |
||
126 | 129 | $args = $this->parser->parseArgs($rule); |
127 | 130 | $message = $this->parser->parseMessage($rule); |
128 | 131 | |
129 | - if (!is_array($check)) { |
|
132 | + if (!is_array($check)) |
|
133 | + { |
|
130 | 134 | return new CallableRule($check, $args, $message); |
131 | 135 | } |
132 | 136 | |
133 | - if (is_string($check[0]) && $this->config->hasChecker($check[0])) { |
|
137 | + if (is_string($check[0]) && $this->config->hasChecker($check[0])) |
|
138 | + { |
|
134 | 139 | $check[0] = $this->config->getChecker($check[0])->resolve($this->factory); |
135 | 140 | |
136 | 141 | return new CheckerRule($check[0], $check[1], $args, $message); |
137 | 142 | } |
138 | 143 | |
139 | - if (!is_object($check[0])) { |
|
144 | + if (!is_object($check[0])) |
|
145 | + { |
|
140 | 146 | $check[0] = (new Autowire($check[0]))->resolve($this->factory); |
141 | 147 | } |
142 | 148 | |
@@ -151,17 +157,22 @@ discard block |
||
151 | 157 | */ |
152 | 158 | protected function makeConditions(array $conditions): ?\SplObjectStorage |
153 | 159 | { |
154 | - if (empty($conditions)) { |
|
160 | + if (empty($conditions)) |
|
161 | + { |
|
155 | 162 | return null; |
156 | 163 | } |
157 | 164 | |
158 | 165 | $storage = new \SplObjectStorage(); |
159 | - foreach ($conditions as $condition => $options) { |
|
166 | + foreach ($conditions as $condition => $options) |
|
167 | + { |
|
160 | 168 | $condition = $this->config->resolveAlias($condition); |
161 | 169 | |
162 | - if ($this->config->hasCondition($condition)) { |
|
170 | + if ($this->config->hasCondition($condition)) |
|
171 | + { |
|
163 | 172 | $autowire = $this->config->getCondition($condition); |
164 | - } else { |
|
173 | + } |
|
174 | + else |
|
175 | + { |
|
165 | 176 | $autowire = new Autowire($condition); |
166 | 177 | } |
167 | 178 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function size($file, int $size): bool |
80 | 80 | { |
81 | - if (empty($filename = $this->resolveFilename($file))) { |
|
81 | + if (empty($filename = $this->resolveFilename($file))){ |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function extension($file, $extensions): bool |
98 | 98 | { |
99 | - if (!is_array($extensions)) { |
|
99 | + if (!is_array($extensions)){ |
|
100 | 100 | $extensions = array_slice(func_get_args(), 1); |
101 | 101 | } |
102 | 102 | |
103 | - if ($file instanceof UploadedFileInterface) { |
|
103 | + if ($file instanceof UploadedFileInterface){ |
|
104 | 104 | return in_array( |
105 | 105 | $this->files->extension($file->getClientFilename()), |
106 | 106 | $extensions, |
@@ -78,7 +78,8 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function size($file, int $size): bool |
80 | 80 | { |
81 | - if (empty($filename = $this->resolveFilename($file))) { |
|
81 | + if (empty($filename = $this->resolveFilename($file))) |
|
82 | + { |
|
82 | 83 | return false; |
83 | 84 | } |
84 | 85 | |
@@ -96,11 +97,13 @@ discard block |
||
96 | 97 | */ |
97 | 98 | public function extension($file, $extensions): bool |
98 | 99 | { |
99 | - if (!is_array($extensions)) { |
|
100 | + if (!is_array($extensions)) |
|
101 | + { |
|
100 | 102 | $extensions = array_slice(func_get_args(), 1); |
101 | 103 | } |
102 | 104 | |
103 | - if ($file instanceof UploadedFileInterface) { |
|
105 | + if ($file instanceof UploadedFileInterface) |
|
106 | + { |
|
104 | 107 | return in_array( |
105 | 108 | $this->files->extension($file->getClientFilename()), |
106 | 109 | $extensions, |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | public function type($file, $types): bool |
91 | 91 | { |
92 | 92 | $image = $this->imageData($file); |
93 | - if ($image === false) { |
|
93 | + if ($image === false){ |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
97 | - if (!is_array($types)) { |
|
97 | + if (!is_array($types)){ |
|
98 | 98 | $types = array_slice(func_get_args(), 1); |
99 | 99 | } |
100 | 100 | |
101 | - if (!isset(self::IMAGE_TYPES[$image[self::IMAGE_TYPE]])) { |
|
101 | + if (!isset(self::IMAGE_TYPES[$image[self::IMAGE_TYPE]])){ |
|
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function smaller($file, int $width, int $height): bool |
128 | 128 | { |
129 | - if (empty($image = $this->imageData($file))) { |
|
129 | + if (empty($image = $this->imageData($file))){ |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function bigger($file, int $width, int $height = null): bool |
146 | 146 | { |
147 | - if (empty($image = $this->imageData($file))) { |
|
147 | + if (empty($image = $this->imageData($file))){ |
|
148 | 148 | return false; |
149 | 149 | } |
150 | 150 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | protected function imageData($file) |
163 | 163 | { |
164 | 164 | $filename = $this->resolveFilename($file); |
165 | - if (empty($filename)) { |
|
165 | + if (empty($filename)){ |
|
166 | 166 | return false; |
167 | 167 | } |
168 | 168 |
@@ -90,15 +90,18 @@ discard block |
||
90 | 90 | public function type($file, $types): bool |
91 | 91 | { |
92 | 92 | $image = $this->imageData($file); |
93 | - if ($image === false) { |
|
93 | + if ($image === false) |
|
94 | + { |
|
94 | 95 | return false; |
95 | 96 | } |
96 | 97 | |
97 | - if (!is_array($types)) { |
|
98 | + if (!is_array($types)) |
|
99 | + { |
|
98 | 100 | $types = array_slice(func_get_args(), 1); |
99 | 101 | } |
100 | 102 | |
101 | - if (!isset(self::IMAGE_TYPES[$image[self::IMAGE_TYPE]])) { |
|
103 | + if (!isset(self::IMAGE_TYPES[$image[self::IMAGE_TYPE]])) |
|
104 | + { |
|
102 | 105 | return false; |
103 | 106 | } |
104 | 107 | |
@@ -126,7 +129,8 @@ discard block |
||
126 | 129 | */ |
127 | 130 | public function smaller($file, int $width, int $height): bool |
128 | 131 | { |
129 | - if (empty($image = $this->imageData($file))) { |
|
132 | + if (empty($image = $this->imageData($file))) |
|
133 | + { |
|
130 | 134 | return false; |
131 | 135 | } |
132 | 136 | |
@@ -144,7 +148,8 @@ discard block |
||
144 | 148 | */ |
145 | 149 | public function bigger($file, int $width, int $height = null): bool |
146 | 150 | { |
147 | - if (empty($image = $this->imageData($file))) { |
|
151 | + if (empty($image = $this->imageData($file))) |
|
152 | + { |
|
148 | 153 | return false; |
149 | 154 | } |
150 | 155 | |
@@ -162,7 +167,8 @@ discard block |
||
162 | 167 | protected function imageData($file) |
163 | 168 | { |
164 | 169 | $filename = $this->resolveFilename($file); |
165 | - if (empty($filename)) { |
|
170 | + if (empty($filename)) |
|
171 | + { |
|
166 | 172 | return false; |
167 | 173 | } |
168 | 174 |
@@ -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 |