| Total Complexity | 10 |
| Total Lines | 101 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class ReCaptcha3Validator implements FormValidatorInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * |
||
| 13 | */ |
||
| 14 | protected $reCaptcha; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * |
||
| 18 | */ |
||
| 19 | protected $secret; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | protected $action = ''; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @var float |
||
| 28 | */ |
||
| 29 | protected $minScore = 0.5; |
||
| 30 | |||
| 31 | public const URL = 'https://www.google.com/recaptcha/api/siteverify'; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * |
||
| 35 | */ |
||
| 36 | public function __construct(string $reCaptcha, string $secret) |
||
| 37 | { |
||
| 38 | $this->reCaptcha = $reCaptcha; |
||
| 39 | $this->secret = $secret; |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get the value of action |
||
| 44 | * |
||
| 45 | * @return string |
||
| 46 | */ |
||
| 47 | public function getAction(): string |
||
| 48 | { |
||
| 49 | return $this->action; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Set the value of action |
||
| 54 | * |
||
| 55 | * @param string $action |
||
| 56 | * |
||
| 57 | * @return self |
||
| 58 | */ |
||
| 59 | public function setAction(string $action) |
||
| 60 | { |
||
| 61 | $this->action = $action; |
||
| 62 | |||
| 63 | return $this; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Get the value of minScore |
||
| 68 | * |
||
| 69 | * @return float |
||
| 70 | */ |
||
| 71 | public function getMinScore(): float |
||
| 72 | { |
||
| 73 | return $this->minScore; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Set the value of minScore |
||
| 78 | * |
||
| 79 | * @param float $minScore |
||
| 80 | * |
||
| 81 | * @return self |
||
| 82 | */ |
||
| 83 | public function setMinScore(float $minScore) |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * |
||
| 92 | */ |
||
| 93 | public function isValid(ServerRequestInterface $request): bool |
||
| 112 |