Completed
Push — master ( 1c4beb...da5a36 )
by Richan
01:11
created

UncacheableByVarnish::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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 \Symfony\Component\HttpFoundation\Response
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