SystemServiceProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 15 1
1
<?php
2
namespace Sovereign\Service;
3
4
use League\Container\ServiceProvider\AbstractServiceProvider;
5
6
class SystemServiceProvider extends AbstractServiceProvider
7
{
8
    /**
9
     * The provides array is a way to let the container
10
     * know that a service is provided by this service
11
     * provider. Every service that is registered via
12
     * this service provider must have an alias added
13
     * to this array or it will be ignored.
14
     *
15
     * @var array
16
     */
17
    protected $provides = [
18
        'log',
19
        'db',
20
        'config',
21
        'curl',
22
        'settings',
23
        'permissions',
24
        'serverConfig',
25
        'users',
26
    ];
27
28
    /**
29
     * This is where the magic happens, within the method you can
30
     * access the container and register or retrieve anything
31
     * that you need to, but remember, every alias registered
32
     * within this method must be declared in the `$provides` array.
33
     */
34
    public function register()
35
    {
36
        $container = $this->getContainer();
37
38
        $container->share('log', 'Monolog\Logger')->withArgument('Sovereign');
39
        $container->get('log')->pushHandler(new \Monolog\Handler\StreamHandler('php://stdout', \Monolog\Logger::INFO));
40
41
        $container->share('db', 'Sovereign\Lib\Db')->withArgument('config')->withArgument('log')->withArgument($container);
42
        $container->share('config', 'Sovereign\Lib\Config')->withArgument('configFile')->withArgument('log');
43
        $container->share('curl', 'Sovereign\Lib\cURL')->withArgument('log');
44
        $container->share('settings', 'Sovereign\Lib\Settings')->withArgument('db');
45
        $container->share('permissions', 'Sovereign\Lib\Permissions')->withArgument('db')->withArgument('config');
46
        $container->share('serverConfig', 'Sovereign\Lib\ServerConfig')->withArgument('db');
47
        $container->share('users', 'Sovereign\Lib\Users')->withArgument('db');
48
    }
49
}
50