Secure::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Distilleries\Expendable\Http\Middleware;
4
5
use Closure;
6
use Illuminate\Contracts\Foundation\Application;
7
8
class Secure {
9
10
    protected $app;
11
12 162
    public function __construct(Application $app)
13
    {
14 162
        $this->app = $app;
15
    }
16
17
    /**
18
     * Handle an incoming request.
19
     *
20
     * @param \Illuminate\Http\Request $request
21
     * @param \Closure $next
22
     * @return mixed
23
     */
24 162
    public function handle($request, Closure $next)
25
    {
26
27 162
        if (!$request->isSecure() and env('SECURE_COOKIE', false)) {
28
            if (strpos($request->getRequestUri(), '/storage/') === false) {
29
                return redirect()->secure($request->getRequestUri());
30
            }
31
32
        }
33
34 162
        return $next($request);
35
    }
36
}