| Conditions | 6 |
| Paths | 7 |
| Total Lines | 22 |
| Code Lines | 12 |
| 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) && !is_null($captchaAdapter)) { |
||
| 30 | throw CaptchaException::unsupportedAdapter($captchaAdapter); |
||
| 31 | }elseif (is_null($captchaAdapter)){ |
||
| 32 | throw new \Exception(''); |
||
| 33 | } |
||
| 34 | |||
| 35 | $captchaAdapterClassName = __NAMESPACE__ . '\\Adapters\\' . ucfirst($captchaAdapter) . 'Adapter'; |
||
| 36 | |||
| 37 | $params = config()->get('captcha.' . $captchaAdapter); |
||
| 38 | return self::$adapter = $captchaAdapterClassName::getInstance($params); |
||
| 39 | } |
||
| 40 | } |