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

Commit 675c48a

Browse files
committed
default curl_timeout in ReCaptchaBuilderInvisible and ReCaptchaBuilderV2 class constructor
1 parent e55c2ae commit 675c48a

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/ReCaptchaBuilderInvisible.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class ReCaptchaBuilderInvisible extends ReCaptchaBuilder {
1919
/**
2020
* ReCaptchaBuilderInvisible constructor.
2121
*
22-
* @param string $api_site_key
23-
* @param string $api_secret_key
24-
* @param int $curl_timeout
22+
* @param string $api_site_key
23+
* @param string $api_secret_key
24+
* @param int|null $curl_timeout
2525
*/
26-
public function __construct(string $api_site_key, string $api_secret_key, int $curl_timeout) {
26+
public function __construct(string $api_site_key, string $api_secret_key, ?int $curl_timeout = ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT) {
2727

2828
parent::__construct($api_site_key, $api_secret_key, 'invisible', $curl_timeout);
2929
}

src/ReCaptchaBuilderV2.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class ReCaptchaBuilderV2 extends ReCaptchaBuilder {
1919
/**
2020
* ReCaptchaBuilderV2 constructor.
2121
*
22-
* @param string $api_site_key
23-
* @param string $api_secret_key
24-
* @param int $curl_timeout
22+
* @param string $api_site_key
23+
* @param string $api_secret_key
24+
* @param int|null $curl_timeout
2525
*/
26-
public function __construct(string $api_site_key, string $api_secret_key, int $curl_timeout) {
26+
public function __construct(string $api_site_key, string $api_secret_key, ?int $curl_timeout = ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT) {
2727

2828
parent::__construct($api_site_key, $api_secret_key, 'v2', $curl_timeout);
2929
}

tests/ReCaptchaTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace Biscolab\ReCaptcha\Tests;
1212

1313
use Biscolab\ReCaptcha\Facades\ReCaptcha;
14+
use Biscolab\ReCaptcha\ReCaptchaBuilder;
1415
use Biscolab\ReCaptcha\ReCaptchaBuilderInvisible;
1516
use Biscolab\ReCaptcha\ReCaptchaBuilderV2;
1617

@@ -72,6 +73,11 @@ public function testReCaptchaInvisibleHtmlFormSnippetShouldThrowError() {
7273
$this->recaptcha_invisible->htmlFormSnippet();
7374
}
7475

76+
public function testDefaultCurlTimeout() {
77+
$this->assertEquals($this->recaptcha_invisible->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
78+
$this->assertEquals($this->recaptcha_v2->getCurlTimeout(), ReCaptchaBuilder::DEFAULT_CURL_TIMEOUT);
79+
}
80+
7581
/**
7682
* @test
7783
* @expectedException \Error
@@ -85,8 +91,8 @@ protected function setUp(): void {
8591

8692
parent::setUp(); // TODO: Change the autogenerated stub
8793

88-
$this->recaptcha_invisible = new ReCaptchaBuilderInvisible('api_site_key', 'api_secret_key', 3);
89-
$this->recaptcha_v2 = new ReCaptchaBuilderV2('api_site_key', 'api_secret_key', 3);
94+
$this->recaptcha_invisible = new ReCaptchaBuilderInvisible('api_site_key', 'api_secret_key');
95+
$this->recaptcha_v2 = new ReCaptchaBuilderV2('api_site_key', 'api_secret_key');
9096

9197
}
9298
}

0 commit comments

Comments
 (0)