Completed
Push — master ( f4d77b...75a886 )
by Richan
13:04
created

CacheableByVarnish   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 1
1
<?php
2
3
namespace RichanFongdasen\Varnishable\Middleware;
4
5
use Closure;
6
7
class CacheableByVarnish
8
{
9
    /**
10
     * Handle an incoming request.
11
     *
12
     * @param  \Illuminate\Http\Request  $request
13
     * @param  \Closure  $next
14
     * @return mixed
15
     */
16
    public function handle($request, Closure $next, int $cacheDuration = null)
17
    {
18
        \Varnishable::setRequestHeaders($request->headers);
19
20
        $response = $next($request);
21
22
        return \Varnishable::manipulate($response, $cacheDuration);
23
    }
24
}
25