LaravelDbEventsServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 34
c 1
b 0
f 0
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 7 1
A registerConnector() 0 12 2
1
<?php
2
namespace ShiftOneLabs\LaravelDbEvents;
3
4
use Illuminate\Support\ServiceProvider;
5
6
class LaravelDbEventsServiceProvider extends ServiceProvider
7
{
8
9
    /**
10
     * Register any application services.
11
     *
12
     * @return void
13
     */
14 59
    public function register()
15
    {
16 59
        $this->registerConnector('mysql', 'ShiftOneLabs\LaravelDbEvents\Extension\Database\Connectors\MySqlConnector');
17 59
        $this->registerConnector('pgsql', 'ShiftOneLabs\LaravelDbEvents\Extension\Database\Connectors\PostgresConnector');
18 59
        $this->registerConnector('sqlite', 'ShiftOneLabs\LaravelDbEvents\Extension\Database\Connectors\SQLiteConnector');
19 59
        $this->registerConnector('sqlsrv', 'ShiftOneLabs\LaravelDbEvents\Extension\Database\Connectors\SqlServerConnector');
20 59
    }
21
22
    /**
23
     * Register any application services.
24
     *
25
     * @return void
26
     */
27
    public function registerConnector($driver, $class)
28
    {
29 59
        $this->app->bind('db.connector.'.$driver, function ($app) use ($class) {
30 55
            $connector = new $class();
31
32 55
            if ($app->bound('events')) {
33 55
                $connector->setEventDispatcher($app['events']);
34 55
            }
35
36 55
            return $connector;
37 59
        });
38 59
    }
39
}
40