CacheWithVarnish   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 1
1
<?php
2
3
namespace DeltaBlue\Varnish\Middleware;
4
5
use Closure;
6
7
class CacheWithVarnish
8
{
9
    public function handle($request, Closure $next, int $cacheTimeInMinutes = null)
10
    {
11
        $response = $next($request);
12
13
        return $response->withHeaders([
14
            config('varnish.cacheable_header_name') => '1',
15
            'Cache-Control' => 'public, max-age='. 60 * ($cacheTimeInMinutes ?? config('varnish.cache_time_in_minutes')),
16
        ]);
17
    }
18
}
19