StackTurbolinks   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A handle() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of the Helthe Turbolinks package.
5
 *
6
 * (c) Carl Alexander <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Helthe\Component\Turbolinks;
13
14
use Symfony\Component\HttpFoundation\Request;
15
use Symfony\Component\HttpKernel\HttpKernelInterface;
16
17
/**
18
 * Stack middleware for Turbolinks.
19
 *
20
 * @author Carl Alexander <[email protected]>
21
 */
22
class StackTurbolinks implements HttpKernelInterface
23
{
24
    /**
25
     * @var HttpKernelInterface
26
     */
27
    private $app;
28
29
    /**
30
     * @var Turbolinks
31
     */
32
    private $turbolinks;
33
34
    /**
35
     * Constructor.
36
     *
37
     * @param HttpKernelInterface $app
38
     * @param Turbolinks          $turbolinks
39
     */
40
    public function __construct(HttpKernelInterface $app, Turbolinks $turbolinks)
41
    {
42
        $this->app = $app;
43
        $this->turbolinks = $turbolinks;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
50
    {
51
        $response = $this->app->handle($request, $type, $catch);
52
53
        if (self::MASTER_REQUEST === $type) {
54
            $this->turbolinks->decorateResponse($request, $response);
55
        }
56
57
        return $response;
58
    }
59
}
60