TrackItServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
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