Passed
Push — master ( bba981...a1f61b )
by Stephen
02:25
created

HoneyPot   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 12 4
1
<?php
2
3
namespace Sfneal\Honeypot\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use Spatie\Honeypot\ProtectAgainstSpam;
8
use Symfony\Component\HttpFoundation\Response;
9
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 (
24
            $request->has('data.name_first')
25
            && $request->has('data.name_last')
26
            && $request->input('data.name_first') == $request->input('data.name_last')
27
        ) {
28
            return $this->respondToSpam($request, $next);
29
        }
30
31
        return parent::handle($request, $next);
32
    }
33
}
34