Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 3 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
AbstractBase | |
0.00% |
0 / 3 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
getJsIncludes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getErrorMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
verify | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | |
3 | /** |
4 | * Abstract base CAPTCHA |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2020. |
9 | * |
10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2, |
12 | * as published by the Free Software Foundation. |
13 | * |
14 | * This program is distributed in the hope that it will be useful, |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | * GNU General Public License for more details. |
18 | * |
19 | * You should have received a copy of the GNU General Public License |
20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
22 | * |
23 | * @category VuFind |
24 | * @package CAPTCHA |
25 | * @author Mario Trojan <mario.trojan@uni-tuebingen.de> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org/wiki/development Wiki |
28 | */ |
29 | |
30 | namespace VuFind\Captcha; |
31 | |
32 | use Laminas\Mvc\Controller\Plugin\Params; |
33 | |
34 | use function get_class; |
35 | |
36 | /** |
37 | * Abstract base CAPTCHA |
38 | * |
39 | * @category VuFind |
40 | * @package CAPTCHA |
41 | * @author Mario Trojan <mario.trojan@uni-tuebingen.de> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org/wiki/development Wiki |
44 | */ |
45 | abstract class AbstractBase |
46 | { |
47 | /** |
48 | * Get list of URLs with JS dependencies to load for the active CAPTCHA type. |
49 | * |
50 | * @return array |
51 | */ |
52 | public function getJsIncludes(): array |
53 | { |
54 | return []; |
55 | } |
56 | |
57 | /** |
58 | * Get ID for current CAPTCHA (to use e.g. in HTML forms) |
59 | * |
60 | * @return string |
61 | */ |
62 | public function getId(): string |
63 | { |
64 | return preg_replace('"^.*\\\\"', '', get_class($this)); |
65 | } |
66 | |
67 | /** |
68 | * Get any error message after a failed captcha verification. The message can be |
69 | * displayed to the user. |
70 | * |
71 | * @return string |
72 | */ |
73 | public function getErrorMessage(): string |
74 | { |
75 | return 'captcha_not_passed'; |
76 | } |
77 | |
78 | /** |
79 | * Pull the captcha field from controller params and check them for accuracy |
80 | * |
81 | * @param Params $params Controller params |
82 | * |
83 | * @return bool |
84 | */ |
85 | abstract public function verify(Params $params): bool; |
86 | } |