Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit 931aef4

Browse files
committed
default_timeout removed from builder constructor
1 parent 98fba27 commit 931aef4

File tree

5 files changed

+13
-38
lines changed

5 files changed

+13
-38
lines changed

src/ReCaptchaBuilder.php

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@ class ReCaptchaBuilder {
5050
*/
5151
protected $version;
5252

53-
/**
54-
* The curl timeout
55-
* please visit https://curl.haxx.se/libcurl/c/CURLOPT_TIMEOUT.html
56-
* @var int
57-
*/
58-
protected $curl_timeout;
59-
6053
/**
6154
* Whether is true the ReCAPTCHA is inactive
6255
* @var boolean
@@ -74,19 +67,16 @@ class ReCaptchaBuilder {
7467
* @param string $api_site_key
7568
* @param string $api_secret_key
7669
* @param null|string $version
77-
* @param int|null $curl_timeout
7870
*/
7971
public function __construct(
8072
string $api_site_key,
8173
string $api_secret_key,
82-
?string $version = self::DEFAULT_API_VERSION,
83-
?int $curl_timeout = self::DEFAULT_CURL_TIMEOUT
74+
?string $version = self::DEFAULT_API_VERSION
8475
) {
8576

8677
$this->setApiSiteKey($api_site_key);
8778
$this->setApiSecretKey($api_secret_key);
8879
$this->setVersion($version);
89-
$this->setCurlTimeout($curl_timeout);
9080
$this->setSkipByIp($this->skipByIp());
9181
}
9282

@@ -114,27 +104,12 @@ public function setApiSecretKey(string $api_secret_key): ReCaptchaBuilder {
114104
return $this;
115105
}
116106

117-
/**
118-
* @param int|null $curl_timeout
119-
*
120-
* @return ReCaptchaBuilder
121-
*/
122-
public function setCurlTimeout(?int $curl_timeout = null): ReCaptchaBuilder {
123-
124-
if($curl_timeout === null) {
125-
$curl_timeout = config('recaptcha.curl_timeout', ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
126-
}
127-
$this->curl_timeout = $curl_timeout;
128-
129-
return $this;
130-
}
131-
132107
/**
133108
* @return int
134109
*/
135110
public function getCurlTimeout(): int {
136111

137-
return $this->curl_timeout;
112+
return config('recaptcha.curl_timeout', self::DEFAULT_CURL_TIMEOUT);
138113
}
139114

140115
/**
@@ -322,7 +297,7 @@ public function validate($response) {
322297
$curl = curl_init($url);
323298
curl_setopt($curl, CURLOPT_HEADER, false);
324299
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
325-
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
300+
curl_setopt($curl, CURLOPT_TIMEOUT, $this->getCurlTimeout());
326301
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
327302
$curl_response = curl_exec($curl);
328303
}

src/ReCaptchaBuilderInvisible.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class ReCaptchaBuilderInvisible extends ReCaptchaBuilder {
2121
*
2222
* @param string $api_site_key
2323
* @param string $api_secret_key
24-
* @param int|null $curl_timeout
2524
*/
26-
public function __construct(string $api_site_key, string $api_secret_key, ?int $curl_timeout = null) {
25+
public function __construct(string $api_site_key, string $api_secret_key)
26+
{
2727

28-
parent::__construct($api_site_key, $api_secret_key, 'invisible', $curl_timeout);
28+
parent::__construct($api_site_key, $api_secret_key, 'invisible');
2929
}
3030

3131
/**

src/ReCaptchaBuilderV2.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class ReCaptchaBuilderV2 extends ReCaptchaBuilder {
2121
*
2222
* @param string $api_site_key
2323
* @param string $api_secret_key
24-
* @param int|null $curl_timeout
2524
*/
26-
public function __construct(string $api_site_key, string $api_secret_key, ?int $curl_timeout = null) {
25+
public function __construct(string $api_site_key, string $api_secret_key)
26+
{
2727

28-
parent::__construct($api_site_key, $api_secret_key, 'v2', $curl_timeout);
28+
parent::__construct($api_site_key, $api_secret_key, 'v2');
2929
}
3030

3131
/**

src/ReCaptchaBuilderV3.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class ReCaptchaBuilderV3 extends ReCaptchaBuilder {
2121
*
2222
* @param string $api_site_key
2323
* @param string $api_secret_key
24-
* @param int|null $curl_timeout
2524
*/
26-
public function __construct(string $api_site_key, string $api_secret_key, ?int $curl_timeout = null) {
25+
public function __construct(string $api_site_key, string $api_secret_key)
26+
{
2727

28-
parent::__construct($api_site_key, $api_secret_key, 'v3', $curl_timeout);
28+
parent::__construct($api_site_key, $api_secret_key, 'v3');
2929
}
3030

3131
}

src/ReCaptchaServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected function registerReCaptchaBuilder() {
114114
break;
115115
}
116116

117-
return new $recaptcha_class(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'), config('recaptcha.curl_timeout'));
117+
return new $recaptcha_class(config('recaptcha.api_site_key'), config('recaptcha.api_secret_key'));
118118

119119
});
120120
}

0 commit comments

Comments
 (0)