diff --git a/src/ReCaptcha.php b/src/ReCaptcha.php index cf1a3db..225a334 100644 --- a/src/ReCaptcha.php +++ b/src/ReCaptcha.php @@ -19,11 +19,11 @@ use const E_USER_WARNING; /** - * Render and verify ReCaptchas + * Render and verify v2 ReCaptchas * * @final This class should not be extended and will be marked final in version 4.0 */ -class ReCaptcha implements Stringable +class ReCaptcha implements ReCaptchaServiceInterface, Stringable { /** * URI to the API @@ -185,11 +185,7 @@ public function getIp() } /** - * Set a single parameter - * - * @param string $key - * @param mixed $value - * @return self + * @inheritDoc */ public function setParam($key, $value) { @@ -227,9 +223,7 @@ public function setParams($params) } /** - * Get the parameter array - * - * @return array + * @inheritDoc */ public function getParams() { @@ -252,11 +246,7 @@ public function getParam($key) } /** - * Set a single option - * - * @param string $key - * @param mixed $value - * @return self + * @inheritDoc */ public function setOption($key, $value) { @@ -269,7 +259,7 @@ public function setOption($key, $value) * Set options * * @param iterable $options - * @return self + * @return $this * @throws Exception */ public function setOptions($options) @@ -290,9 +280,7 @@ public function setOptions($options) } /** - * Get the options array - * - * @return array + * @inheritDoc */ public function getOptions() { @@ -315,9 +303,7 @@ public function getOption($key) } /** - * Get the site key - * - * @return string + * @inheritDoc */ public function getSiteKey() { @@ -325,10 +311,7 @@ public function getSiteKey() } /** - * Set the site key - * - * @param string $siteKey - * @return self + * @inheritDoc */ public function setSiteKey($siteKey) { @@ -338,9 +321,7 @@ public function setSiteKey($siteKey) } /** - * Get the secret key - * - * @return string + * @inheritDoc */ public function getSecretKey() { @@ -348,10 +329,7 @@ public function getSecretKey() } /** - * Set the secret key - * - * @param string $secretKey - * @return self + * @inheritDoc */ public function setSecretKey($secretKey) { @@ -478,17 +456,14 @@ protected function post($responseField) } /** - * Verify the user input + * {@inheritDoc} * * This method calls up the post method and returns a * \Laminas\ReCaptcha\Response object. - * - * @param string $responseField - * @return Response */ public function verify($responseField) { $response = $this->post($responseField); - return new Response(null, null, $response); + return new Response(null, [], $response); } } diff --git a/src/ReCaptchaServiceInterface.php b/src/ReCaptchaServiceInterface.php new file mode 100644 index 0000000..f80dd72 --- /dev/null +++ b/src/ReCaptchaServiceInterface.php @@ -0,0 +1,81 @@ + + */ + public function getOptions(); + + /** + * Set a single option + * + * @param string $key + * @param mixed $value + * @return $this + */ + public function setOption($key, $value); + + /** + * Get the parameter array + * + * @return array + */ + public function getParams(); + + /** + * Set a single parameter + * + * @param string $key + * @param mixed $value + * @return $this + */ + public function setParam($key, $value); + + /** + * Get the site key + * + * @return string + */ + public function getSiteKey(); + + /** + * Set the site key + * + * @param string $siteKey + * @return $this + */ + public function setSiteKey($siteKey); + + /** + * Get the secret key + * + * @return string + */ + public function getSecretKey(); + + /** + * Set the secret key + * + * @param string $secretKey + * @return $this + */ + public function setSecretKey($secretKey); + + /** + * Verify the user input + * + * @param string $responseField + * @return Response + */ + public function verify($responseField); +}