1 | <?php |
||
14 | class Honeypot |
||
15 | { |
||
16 | use Utils\FormTrait; |
||
17 | |||
18 | const KEY_GENERATOR = 'HONEYPOT_GENERATOR'; |
||
19 | |||
20 | /** |
||
21 | * @var string The honeypot input name |
||
22 | */ |
||
23 | private $inputName = 'hpt_name'; |
||
24 | |||
25 | /** |
||
26 | * @var string The honeypot class name |
||
27 | */ |
||
28 | private $inputClass = 'hpt_input'; |
||
29 | |||
30 | /** |
||
31 | * Returns a callable to generate the inputs. |
||
32 | * |
||
33 | * @param ServerRequestInterface $request |
||
34 | * |
||
35 | * @return callable|null |
||
36 | */ |
||
37 | public static function getGenerator(ServerRequestInterface $request) |
||
41 | |||
42 | /** |
||
43 | * Set the field name. |
||
44 | * |
||
45 | * @param string $inputName |
||
46 | * |
||
47 | * @return self |
||
48 | */ |
||
49 | public function inputName($inputName) |
||
55 | |||
56 | /** |
||
57 | * Set the field class. |
||
58 | * |
||
59 | * @param string $inputClass |
||
60 | * |
||
61 | * @return self |
||
62 | */ |
||
63 | public function inputClass($inputClass) |
||
69 | |||
70 | /** |
||
71 | * Execute the middleware. |
||
72 | * |
||
73 | * @param ServerRequestInterface $request |
||
74 | * @param ResponseInterface $response |
||
75 | * @param callable $next |
||
76 | * |
||
77 | * @return ResponseInterface |
||
78 | */ |
||
79 | public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) |
||
103 | |||
104 | /** |
||
105 | * Check whether the request is valid. |
||
106 | * |
||
107 | * @param ServerRequestInterface $request |
||
108 | * |
||
109 | * @return bool |
||
110 | */ |
||
111 | private function isValid(ServerRequestInterface $request) |
||
117 | } |
||
118 |