SanitizeInput::sanitizeInput()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use Closure;
6
7
class SanitizeInput
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param \Illuminate\Http\Request $request
13
     * @param \Closure                 $next
14
     *
15
     * @return mixed
16
     */
17
    public function handle($request, Closure $next)
18
    {
19
        $this->sanitizeInput($request);
20
21
        return $next($request);
22
    }
23
24
    /**
25
     * Sanitize the form input from a request.
26
     *
27
     * @param \Illuminate\Http\Request $request
28
     *
29
     * @return mixed
30
     */
31
    protected function sanitizeInput($request)
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
32
    {
33
        $sanitized = [];
34
35
        if ($request->has('email')) {
36
            $email = $request->get('email');
37
            $sanitized['email'] = trim($email, ' ');
38
        }
39
40
        $request->merge($sanitized);
41
    }
42
}
43