| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class HoneyPot extends ProtectAgainstSpam |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Check if 'first' & 'last' name inputs are the same. |
||
| 14 | * |
||
| 15 | * @param Request $request |
||
| 16 | * @param Closure $next |
||
| 17 | * |
||
| 18 | * @return Response |
||
| 19 | */ |
||
| 20 | public function handle(Request $request, Closure $next): Response |
||
| 21 | { |
||
| 22 | // Check if first & last name inputs are the same (typical of spam) |
||
| 23 | if ($this->requestHasTraps($request)) { |
||
| 24 | return $this->respondToSpam($request, $next); |
||
| 25 | } |
||
| 26 | |||
| 27 | // Pass request to parent `ProtectAgainstSpam` handler |
||
| 28 | return parent::handle($request, $next); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Determine if a Request contains Honeypot traps. |
||
| 33 | * |
||
| 34 | * @param Request $request |
||
| 35 | * @return bool |
||
| 36 | */ |
||
| 37 | private function requestHasTraps(Request $request): bool |
||
| 51 | } |
||
| 52 | } |
||
| 53 |