Completed
Push — phpstan-fixes ( f3f29e )
by Richan
01:15
created

UncacheableByVarnish   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 8 1
1
<?php
2
3
namespace RichanFongdasen\Varnishable\Middleware;
4
5
use Closure;
6
use RichanFongdasen\Varnishable\VarnishableService;
7
use Symfony\Component\HttpFoundation\Request;
8
9
class UncacheableByVarnish
10
{
11
    /**
12
     * Varnishable Service Object.
13
     *
14
     * @var \RichanFongdasen\Varnishable\VarnishableService
15
     */
16
    protected $varnishable;
17
18
    /**
19
     * UncacheableByVarnish Middleware constructor.
20
     */
21
    public function __construct()
22
    {
23
        $this->varnishable = app(VarnishableService::class);
24
    }
25
26
    /**
27
     * Handle an incoming request.
28
     *
29
     * @param \Symfony\Component\HttpFoundation\Request $request
30
     * @param \Closure                                  $next
31
     *
32
     * @return mixed
33
     */
34
    public function handle(Request $request, Closure $next)
35
    {
36
        $response = $next($request);
37
38
        $this->varnishable->addUncacheableHeader($response);
39
40
        return $response;
41
    }
42
}
43