DatabaseServiceProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 16
ccs 0
cts 8
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php namespace Bosnadev\Database;
2
3
use Bosnadev\Database\Connectors\ConnectionFactory;
4
use Illuminate\Database\DatabaseManager;
5
6
/**
7
 * Class DatabaseServiceProvider
8
 * @package Bosnadev\Database
9
 */
10
class DatabaseServiceProvider extends \Illuminate\Database\DatabaseServiceProvider
11
{
12
    /**
13
     * Register the service provider.
14
     *
15
     * @return void
16
     */
17
    public function register()
18
    {
19
        // The connection factory is used to create the actual connection instances on
20
        // the database. We will inject the factory into the manager so that it may
21
        // make the connections while they are actually needed and not of before.
22
        $this->app->singleton('db.factory', function ($app) {
23
            return new ConnectionFactory($app);
24
        });
25
26
        // The database manager is used to resolve various connections, since multiple
27
        // connections might be managed. It also implements the connection resolver
28
        // interface which may be used by other components requiring connections.
29
        $this->app->singleton('db', function ($app) {
30
            return new DatabaseManager($app, $app['db.factory']);
31
        });
32
    }
33
}
34