Completed
Push — master ( f4b826...4d0daa )
by Chris
04:52 queued 02:17
created

MySqlService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 1
1
<?php
2
namespace Darya\Foundation\Providers;
3
4
use Darya\Database\Connection\MySql;
5
use Darya\Database\Factory;
6
use Darya\Service\Contracts\Container;
7
use Darya\Service\Contracts\Provider;
8
9
/**
10
 * A service provider that provides a MySQL connection using the configuration
11
 * registered with the service container.
12
 * 
13
 * @author Chris Andrew <[email protected]>
14
 */
15
class MySqlService implements Provider
16
{
17
    public function register(Container $container)
18
    {
19
        $container->register(array(
20
            'Darya\Database\Connection' => function ($container) {
21
                $config = $container->config;
22
                
23
                $connection = new MySql(
24
                    $config['database.hostname'],
25
                    $config['database.username'],
26
                    $config['database.password'],
27
                    $config['database.database']
28
                );
29
                
30
                $connection->setEventDispatcher($container->event);
31
                
32
                return $connection;
33
            }
34
        ));
35
    }
36
}
37