Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Captcha | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| getInstance | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The main Captcha class. |
| 5 | * |
| 6 | * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 7 | * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 8 | * obtain one at https://mozilla.org/MPL/2.0/. |
| 9 | * |
| 10 | * @package phpMyFAQ |
| 11 | * @author Thorsten Rinne <thorsten@phpmyfaq.de> |
| 12 | * @copyright 2023-2026 phpMyFAQ Team |
| 13 | * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 14 | * @link https://www.phpmyfaq.de |
| 15 | * @since 2023-02-11 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace phpMyFAQ\Captcha; |
| 21 | |
| 22 | use phpMyFAQ\Configuration; |
| 23 | |
| 24 | class Captcha |
| 25 | { |
| 26 | private static ?CaptchaInterface $captcha = null; |
| 27 | |
| 28 | private static Configuration $configuration; |
| 29 | |
| 30 | public static function getInstance(Configuration $configuration): BuiltinCaptcha|GoogleRecaptcha |
| 31 | { |
| 32 | self::$configuration = $configuration; |
| 33 | self::$captcha = new BuiltinCaptcha(self::$configuration); |
| 34 | |
| 35 | if (self::$configuration->get('security.enableGoogleReCaptchaV2')) { |
| 36 | self::$captcha = new GoogleRecaptcha(self::$configuration); |
| 37 | } |
| 38 | |
| 39 | return self::$captcha; |
| 40 | } |
| 41 | } |