Test Failed
Push — master ( 0b650e...b4d0bc )
by Chris
19:25
created

AuthenticatesWithReCaptchaTrait::reCaptcha()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Leonidas\Framework\Site\Form;
4
5
use Leonidas\Framework\Abstracts\UtilizesExtensionTrait;
6
use ReCaptcha\ReCaptcha;
7
use WebTheory\Saveyour\Auth\Policy\ReCaptchaPolicy;
8
use WebTheory\Saveyour\Field\Type\Hidden;
9
10
trait AuthenticatesWithReCaptchaTrait
11
{
12
    use UtilizesExtensionTrait;
13
14
    protected function reCaptchaFormCheck(): string
15
    {
16
        return (new Hidden())
17
            ->setId($response = $this->reCaptchaResponse())
18
            ->setName($response)
19
            ->toHtml();
20
    }
21
22
    protected function reCaptchaResponse(): string
23
    {
24
        return 'g-recaptcha-response';
25
    }
26
27
    protected function reCaptchaPolicy(string $response): ReCaptchaPolicy
28
    {
29
        return new ReCaptchaPolicy($response, $this->reCaptcha());
30
    }
31
32
    protected function reCaptcha(): ReCaptcha
33
    {
34
        return new ReCaptcha($this->getConfig('services.recaptcha.secret'));
35
    }
36
}
37