Conditions | 4 |
Paths | 5 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public static function getHandler(): CaptchaInterface |
||
29 | { |
||
30 | if (self::$adapter !== null) { |
||
31 | return self::$adapter; |
||
32 | } |
||
33 | |||
34 | if (!config()->has('captcha')) { |
||
35 | config()->import(new Setup('config', 'captcha')); |
||
36 | } |
||
37 | |||
38 | $captchaAdapter = config()->get('captcha.current'); |
||
39 | |||
40 | if (!in_array($captchaAdapter, self::ADAPTERS)) { |
||
41 | throw CaptchaException::unsupportedAdapter($captchaAdapter); |
||
|
|||
42 | } |
||
43 | |||
44 | $captchaAdapterClassName = __NAMESPACE__ . '\\Adapters\\' . ucfirst($captchaAdapter) . 'Adapter'; |
||
45 | |||
46 | return self::$adapter = $captchaAdapterClassName::getInstance(config()->get('captcha.' . $captchaAdapter), new HttpClient); |
||
47 | } |
||
48 | } |