public function ReCaptcha::__construct in reCAPTCHA 7.2
Same name and namespace in other branches
- 8.2 recaptcha-php/src/ReCaptcha/ReCaptcha.php \ReCaptcha\ReCaptcha::__construct()
- 6.2 recaptcha-php/src/ReCaptcha/ReCaptcha.php \ReCaptcha\ReCaptcha::__construct()
Create a configured instance to use the reCAPTCHA service.
Parameters
string $secret The shared key between your site and reCAPTCHA.:
RequestMethod $requestMethod method used to send the request. Defaults to POST.:
Throws
\RuntimeException if $secret is invalid
File
- recaptcha-php/
src/ ReCaptcha/ ReCaptcha.php, line 125
Class
- ReCaptcha
- reCAPTCHA client.
Namespace
ReCaptchaCode
public function __construct($secret, RequestMethod $requestMethod = null) {
if (empty($secret)) {
throw new \RuntimeException('No secret provided');
}
if (!is_string($secret)) {
throw new \RuntimeException('The provided secret must be a string');
}
$this->secret = $secret;
$this->requestMethod = is_null($requestMethod) ? new RequestMethod\Post() : $requestMethod;
}