GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

GoogleTagManagerMiddleware::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Spatie\GoogleTagManager;
4
5
use Closure;
6
use Illuminate\Config\Repository as Config;
7
use Illuminate\Session\Store as Session;
8
use Spatie\GoogleTagManager\GoogleTagManager;
9
10
class GoogleTagManagerMiddleware
11
{
12
    /**
13
     * @var \Spatie\GoogleTagManager\GoogleTagManager
14
     */
15
    protected $googleTagManager;
16
17
    /**
18
     * @var \Illuminate\Session\Store
19
     */
20
    protected $session;
21
22
    /**
23
     * @var string
24
     */
25
    protected $sessionKey;
26
27
    /**
28
     * @param \Spatie\GoogleTagManager\GoogleTagManager $googleTagManager
29
     * @param \Illuminate\Session\Store $session
30
     */
31
    public function __construct(GoogleTagManager $googleTagManager, Session $session, Config $config)
32
    {
33
        $this->googleTagManager = $googleTagManager;
34
        $this->session = $session;
35
36
        $this->sessionKey = $config->get('googletagmanager.sessionKey');
37
    }
38
39
    /**
40
     * Handle an incoming request.
41
     *
42
     * @param  \Illuminate\Http\Request  $request
43
     * @param  \Closure  $next
44
     * @return mixed
45
     */
46
    public function handle($request, Closure $next)
47
    {
48
        if ($this->session->has($this->sessionKey)) {
49
            $this->googleTagManager->set($this->session->get($this->sessionKey));
50
        }
51
52
        $response = $next($request);
53
54
        $this->session->flash($this->sessionKey, $this->googleTagManager->getFlashData());
55
56
        return $response;
57
    }
58
}
59