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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A handle() 0 12 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