RouteEventSubscriber   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 52
rs 10
c 0
b 0
f 0
ccs 10
cts 10
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A subscribe() 0 6 1
A handle() 0 4 1
1
<?php namespace Arcanedev\LaravelTracker\EventListeners;
2
3
use Arcanedev\LaravelTracker\Contracts\Tracker;
4
use Illuminate\Routing\Events\RouteMatched;
5
use Illuminate\Routing\Route;
6
7
/**
8
 * Class     RouteEventSubscriber
9
 *
10
 * @package  Arcanedev\LaravelTracker\EventListeners
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
class RouteEventSubscriber
14
{
15
    /* -----------------------------------------------------------------
16
     |  Properties
17
     | -----------------------------------------------------------------
18
     */
19
20
    /** @var \Arcanedev\LaravelTracker\Contracts\Tracker */
21
    private $tracker;
22
23
    /* -----------------------------------------------------------------
24
     |  Constructor
25
     | -----------------------------------------------------------------
26
     */
27
28
    /**
29
     * RouteEventSubscriber constructor.
30
     *
31
     * @param  \Arcanedev\LaravelTracker\Contracts\Tracker  $manager
32
     */
33 117
    public function __construct(Tracker $manager)
34
    {
35 117
        $this->tracker = $manager;
36 117
    }
37
38
    /* -----------------------------------------------------------------
39
     |  Main Methods
40
     | -----------------------------------------------------------------
41
     */
42
43
    /**
44
     * Register the listeners for the subscriber.
45
     *
46
     * @param  \Illuminate\Events\Dispatcher  $events
47
     */
48 117
    public function subscribe($events)
49
    {
50 117
        $class = self::class;
51
52 117
        $events->listen(RouteMatched::class, "$class@handle");
53 117
    }
54
55
    /**
56
     * Track the matched route.
57
     *
58
     * @param  \Illuminate\Routing\Events\RouteMatched  $event
59
     */
60 6
    public function handle(RouteMatched $event)
61
    {
62 6
        $this->tracker->trackMatchedRoute($event->route, $event->request);
63 6
    }
64
}
65