@@ -72,7 +72,7 @@ |
||
72 | 72 | { |
73 | 73 | if (!empty($value)) { |
74 | 74 | $captcha = CaptchaManager::getCaptcha(); |
75 | - if (!$captcha->verifyResponse($value)){ |
|
75 | + if (!$captcha->verifyResponse($value)) { |
|
76 | 76 | $this->addError($field, 'captcha', $param); |
77 | 77 | } |
78 | 78 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | public function display($formIdentifier = '', $attributes = []) |
243 | 243 | { |
244 | 244 | if (!empty($this->sitekey)) { |
245 | - if (strtolower($this->type) == 'visible'){ |
|
245 | + if (strtolower($this->type) == 'visible') { |
|
246 | 246 | $data = 'data-sitekey="' . $this->sitekey . '"'; |
247 | 247 | |
248 | 248 | if (!is_null($this->theme)) |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | }) |
270 | 270 | |
271 | 271 | function onSubmit (token){ |
272 | - document.getElementById("'. $formIdentifier .'").submit(); |
|
272 | + document.getElementById("'. $formIdentifier . '").submit(); |
|
273 | 273 | } |
274 | 274 | </script>'; |
275 | 275 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $url = self::VERIFY_URL . '?' . http_build_query($query); |
306 | 306 | |
307 | 307 | $this->http->createRequest($url)->setMethod('GET')->start(); |
308 | - $response = (array)$this->http->getResponseBody(); |
|
308 | + $response = (array) $this->http->getResponseBody(); |
|
309 | 309 | |
310 | 310 | if (empty($response) || is_null($response) || !$response) { |
311 | 311 | return false; |
@@ -139,10 +139,11 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function setTheme($theme = 'light') |
141 | 141 | { |
142 | - if (in_array($theme, self::$themes)) |
|
143 | - $this->theme = $theme; |
|
144 | - else |
|
145 | - throw new \Exception('Theme "' . $theme . '"" is not supported. Available themes : ' . join(', ', self::$themes)); |
|
142 | + if (in_array($theme, self::$themes)) { |
|
143 | + $this->theme = $theme; |
|
144 | + } else { |
|
145 | + throw new \Exception('Theme "' . $theme . '"" is not supported. Available themes : ' . join(', ', self::$themes)); |
|
146 | + } |
|
146 | 147 | |
147 | 148 | return $this; |
148 | 149 | } |
@@ -155,8 +156,9 @@ discard block |
||
155 | 156 | */ |
156 | 157 | public function setType($type = 'image') |
157 | 158 | { |
158 | - if (in_array($type, self::$types)) |
|
159 | - $this->type = $type; |
|
159 | + if (in_array($type, self::$types)) { |
|
160 | + $this->type = $type; |
|
161 | + } |
|
160 | 162 | |
161 | 163 | return $this; |
162 | 164 | } |
@@ -208,8 +210,9 @@ discard block |
||
208 | 210 | public function renderJs($lang = null, $callback = false, $onLoadClass = 'onloadCallBack') |
209 | 211 | { |
210 | 212 | $data = array(); |
211 | - if (!is_null($this->language)) |
|
212 | - $data = array('hl' => $this->language); |
|
213 | + if (!is_null($this->language)) { |
|
214 | + $data = array('hl' => $this->language); |
|
215 | + } |
|
213 | 216 | |
214 | 217 | return '<script src="https://www.google.com/recaptcha/api.js?' . http_build_query($data) . '"></script>'; |
215 | 218 | } |
@@ -245,14 +248,17 @@ discard block |
||
245 | 248 | if (strtolower($this->type) == 'visible'){ |
246 | 249 | $data = 'data-sitekey="' . $this->sitekey . '"'; |
247 | 250 | |
248 | - if (!is_null($this->theme)) |
|
249 | - $data .= ' data-theme="' . $this->theme . '"'; |
|
251 | + if (!is_null($this->theme)) { |
|
252 | + $data .= ' data-theme="' . $this->theme . '"'; |
|
253 | + } |
|
250 | 254 | |
251 | - if (!is_null($this->type)) |
|
252 | - $data .= ' data-type="' . $this->type . '"'; |
|
255 | + if (!is_null($this->type)) { |
|
256 | + $data .= ' data-type="' . $this->type . '"'; |
|
257 | + } |
|
253 | 258 | |
254 | - if (!is_null($this->size)) |
|
255 | - $data .= ' data-size="' . $this->size . '"'; |
|
259 | + if (!is_null($this->size)) { |
|
260 | + $data .= ' data-size="' . $this->size . '"'; |
|
261 | + } |
|
256 | 262 | |
257 | 263 | $captchaEleme = '<div class="col s1 offset-s2 g-recaptcha" ' . $data . '></div>'; |
258 | 264 | } elseif (strtolower($this->type) == 'invisible') { |
@@ -286,8 +292,9 @@ discard block |
||
286 | 292 | */ |
287 | 293 | public function verifyResponse($response, $clientIp = null) |
288 | 294 | { |
289 | - if (is_null($this->secretkey)) |
|
290 | - throw new \Exception('You must set your secret key'); |
|
295 | + if (is_null($this->secretkey)) { |
|
296 | + throw new \Exception('You must set your secret key'); |
|
297 | + } |
|
291 | 298 | |
292 | 299 | if (empty($response)) { |
293 | 300 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function display($formIdentifier = '', $attributes = []) |
77 | 77 | { |
78 | - if (strtolower($this->type) == 'visible'){ |
|
78 | + if (strtolower($this->type) == 'visible') { |
|
79 | 79 | $attributes = $this->prepareAttributes($attributes); |
80 | 80 | $captchaEleme = '<div' . $this->buildAttributes($attributes) . '></div>'; |
81 | 81 | } elseif (strtolower($this->type) == 'invisible') { |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | let button = document.getElementsByTagName("button"); |
89 | 89 | |
90 | 90 | button[0].setAttribute("data-sitekey", "' . $this->sitekey . '"); |
91 | - button[0].setAttribute("data-callback", "'. $functionName .'"); |
|
91 | + button[0].setAttribute("data-callback", "'. $functionName . '"); |
|
92 | 92 | button[0].classList.add("h-captcha"); |
93 | 93 | }) |
94 | 94 | |
95 | - function '. $functionName .'(){ |
|
96 | - document.getElementById("'. $formIdentifier .'").submit(); |
|
95 | + function '. $functionName . '(){ |
|
96 | + document.getElementById("'. $formIdentifier . '").submit(); |
|
97 | 97 | } |
98 | 98 | </script>'; |
99 | 99 | } |
100 | - }else{ |
|
100 | + } else { |
|
101 | 101 | throw CaptchaException::cantConnect(); |
102 | 102 | } |
103 | 103 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | { |
194 | 194 | $this->http->createRequest(static::VERIFY_URL)->setMethod('POST')->setData($query)->start(); |
195 | 195 | |
196 | - return (array)$this->http->getResponseBody(); |
|
196 | + return (array) $this->http->getResponseBody(); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -97,7 +97,7 @@ |
||
97 | 97 | } |
98 | 98 | </script>'; |
99 | 99 | } |
100 | - }else{ |
|
100 | + } else{ |
|
101 | 101 | throw CaptchaException::cantConnect(); |
102 | 102 | } |
103 | 103 |