Completed
Push — master ( 67c338...c7b167 )
by Wanderson
04:24
created

ReCaptcha   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
lcom 1
cbo 0
dl 0
loc 16
rs 10
c 1
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 5 1
1
<?php
2
3
namespace Win\Widget;
4
5
/**
6
 * Validador do ReCaptcha do google
7
 * @author WebCorpore
8
 */
9
class ReCaptcha {
10
11
	public static $siteKey = '';
12
	public static $secretKey = '';
13
14
	/**
15
	 * Retorna TRUE se usuário marcou "Não sou um robô"
16
	 * @return boolean
17
	 */
18
	public static function isValid() {
19
		$captcha = $_POST['g-recaptcha-response'];
20
		$response = json_decode(file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . static::$secretKey . "&response=" . $captcha . "&remoteip=" . $_SERVER['REMOTE_ADDR']), TRUE);
21
		return (boolean) $response['success'];
22
	}
23
24
}
25