Completed
Push — master ( ec2990...7a5f39 )
by ARCANEDEV
07:59
created

AbstractTracker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 70
ccs 11
cts 11
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A config() 0 4 1
A session() 0 4 1
A getConfig() 0 4 1
A make() 0 4 1
1
<?php namespace Arcanedev\LaravelTracker\Trackers;
2
3
use Illuminate\Contracts\Foundation\Application;
4
5
/**
6
 * Class     AbstractTracker
7
 *
8
 * @package  Arcanedev\LaravelTracker\Trackers
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
abstract class AbstractTracker
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /** @var \Illuminate\Contracts\Foundation\Application */
18
    private $app;
19
20
    /* ------------------------------------------------------------------------------------------------
21
     |  Constructor
22
     | ------------------------------------------------------------------------------------------------
23
     */
24
    /**
25
     * AbstractTracker constructor.
26
     */
27 156
    public function __construct(Application $app)
28
    {
29 156
        $this->app = $app;
30 156
    }
31
32
    /* ------------------------------------------------------------------------------------------------
33
     |  Common Functions
34
     | ------------------------------------------------------------------------------------------------
35
     */
36
    /**
37
     * Get the config instance.
38
     *
39
     * @return \Illuminate\Contracts\Config\Repository
40
     */
41 30
    protected function config()
42
    {
43 30
        return $this->make('config');
44
    }
45
46
    /**
47
     * Get the session store instance.
48
     *
49
     * @return \Illuminate\Session\Store
50
     */
51 12
    protected function session()
52
    {
53 12
        return $this->make('session.store');
54
    }
55
56
    /**
57
     * Get the tracker config.
58
     *
59
     * @param  string      $key
60
     * @param  mixed|null  $default
61
     *
62
     * @return mixed
63
     */
64 30
    protected function getConfig($key, $default = null)
65
    {
66 30
        return $this->config()->get("laravel-tracker.$key", $default);
67
    }
68
69
    /**
70
     * Make/Get the instance from the app.
71
     *
72
     * @param  string  $abstract
73
     *
74
     * @return mixed
75
     */
76 66
    protected function make($abstract)
77
    {
78 66
        return $this->app->make($abstract);
79
    }
80
}
81