Completed
Pull Request — master (#5)
by
unknown
03:28
created

LaravelNomadServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Test Coverage

Coverage 84.62%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 6
dl 0
loc 34
ccs 11
cts 13
cp 0.8462
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A register() 0 15 1
1
<?php
2
namespace ShiftOneLabs\LaravelNomad;
3
4
use Illuminate\Database\Connection;
5
use Illuminate\Support\ServiceProvider;
6
use ShiftOneLabs\LaravelNomad\Extension\Database\MySqlConnection;
7
use ShiftOneLabs\LaravelNomad\Extension\Database\PostgresConnection;
8
use ShiftOneLabs\LaravelNomad\Extension\Database\SQLiteConnection;
9
use ShiftOneLabs\LaravelNomad\Extension\Database\SqlServerConnection;
10
11
class LaravelNomadServiceProvider extends ServiceProvider
12
{
13
14
    /**
15
     * Bootstrap any application services.
16
     *
17
     * @return void
18
     */
19
    public function boot()
20
    {
21
        //
22
    }
23
24
    /**
25
     * Register any application services.
26
     *
27
     * @return void
28
     */
29 37
    public function register()
30
    {
31
        Connection::resolverFor('mysql', function ($connection, $database, $prefix, $config) {
32 7
            return new MySqlConnection($connection, $database, $prefix, $config);
33 37
        });
34
        Connection::resolverFor('pgsql', function ($connection, $database, $prefix, $config) {
35 7
            return new PostgresConnection($connection, $database, $prefix, $config);
36 37
        });
37
        Connection::resolverFor('sqlite', function ($connection, $database, $prefix, $config) {
38 7
            return new SQLiteConnection($connection, $database, $prefix, $config);
39 37
        });
40 37
        Connection::resolverFor('sqlsrv', function ($connection, $database, $prefix, $config) {
41 7
            return new SqlServerConnection($connection, $database, $prefix, $config);
42 37
        });
43 37
    }
44
}
45