TrackItServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 33
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 6 1
A register() 0 6 1
A getConfiguredStoreClass() 0 10 2
1
<?php
2
3
namespace Tequilarapido\TrackIt;
4
5
use Tequilarapido\TrackIt\Store\Store;
6
use Illuminate\Support\ServiceProvider;
7
8
class TrackItServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application events.
12
     */
13 8
    public function boot()
14
    {
15 8
        $this->publishes([
16 8
            __DIR__.'/../config/trackit.php' => config_path('trackit.php'),
17
        ]);
18 8
    }
19
20
    /**
21
     * Register the service provider.
22
     */
23 8
    public function register()
24
    {
25 8
        $this->mergeConfigFrom(__DIR__.'/../config/trackit.php', 'trackit');
26
27 8
        $this->app->bind(Store::class, $this->getConfiguredStoreClass());
28 8
    }
29
30 8
    private function getConfiguredStoreClass()
31
    {
32 8
        $driver = ucfirst($this->app['config']['trackit']['store']['driver']);
33
34 8
        if (! class_exists($class = 'Tequilarapido\\TrackIt\\Store\\'.$driver.'Store')) {
35
            throw new \Exception("Cannot find track it store implementation for driver [$driver]");
36
        }
37
38 8
        return $class;
39
    }
40
}
41