Total Complexity | 4 |
Total Lines | 57 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
23 | class HcaptchaAdapter extends BaseCaptcha |
||
24 | { |
||
25 | |||
26 | const VERIFY_URL = 'https://hcaptcha.com/siteverify'; |
||
27 | |||
28 | const CLIENT_API = 'https://hcaptcha.com/1/api.js?onload=onLoadCallback&recaptchacompat=off'; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $name = 'h-captcha'; |
||
34 | |||
35 | /** |
||
36 | * @var string[] |
||
37 | */ |
||
38 | protected $elementClasses = ['h-captcha']; |
||
39 | |||
40 | /** |
||
41 | * @var HcaptchaAdapter |
||
42 | */ |
||
43 | private static $instance = null; |
||
44 | |||
45 | /** |
||
46 | * Hcaptcha constructor |
||
47 | * @param array $params |
||
48 | * @param HttpClient $httpClient |
||
49 | */ |
||
50 | private function __construct(array $params, HttpClient $httpClient) |
||
51 | { |
||
52 | $this->http = $httpClient; |
||
53 | |||
54 | $this->secretKey = $params['secret_key']; |
||
55 | $this->siteKey = $params['site_key']; |
||
56 | $this->type = $params['type'] ?? null; |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Get Instance |
||
61 | * @param array $params |
||
62 | * @param HttpClient $httpClient |
||
63 | * @return HcaptchaAdapter |
||
64 | */ |
||
65 | public static function getInstance(array $params, HttpClient $httpClient): HcaptchaAdapter |
||
66 | { |
||
67 | if (self::$instance === null) { |
||
68 | self::$instance = new self($params, $httpClient); |
||
69 | } |
||
70 | |||
71 | return self::$instance; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return void |
||
76 | */ |
||
77 | public static function resetInstance(): void |
||
80 | } |
||
81 | |||
82 | } |