| Conditions | 4 |
| Paths | 5 |
| Total Lines | 20 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public static function getCaptcha() :CaptchaInterface |
||
| 18 | { |
||
| 19 | if (self::$adapter !== null) { |
||
| 20 | return self::$adapter; |
||
| 21 | } |
||
| 22 | |||
| 23 | if (!config()->has('captcha')) { |
||
| 24 | config()->import(new Setup('config', 'captcha')); |
||
| 25 | } |
||
| 26 | |||
| 27 | $captchaAdapter = config()->get('captcha.current'); |
||
| 28 | |||
| 29 | if (!in_array($captchaAdapter, self::ADAPTERS)) { |
||
| 30 | throw CaptchaException::cantConnect($captchaAdapter); |
||
|
|
|||
| 31 | } |
||
| 32 | |||
| 33 | $captchaAdapterClassName = __NAMESPACE__ . '\\Adapters\\' . ucfirst($captchaAdapter) . 'Adapter'; |
||
| 34 | |||
| 35 | $params = config()->get('captcha.' . $captchaAdapter); |
||
| 36 | return self::$adapter = $captchaAdapterClassName::getInstance($params); |
||
| 37 | } |
||
| 38 | } |