Completed
Push — master ( 601de6...446929 )
by Dmitry
04:40
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 5
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 3
1
<?php
2
3
namespace Basis\Providers;
4
5
use Basis\Config;
6
use Basis\Dispatcher;
7
use Basis\Event;
8
use Basis\Service;
9
use League\Container\ServiceProvider\AbstractServiceProvider;
10
use LinkORB\Component\Etcd\Client;
11
use Tarantool\Mapper\Plugins\Spy;
12
13
class ServiceProvider extends AbstractServiceProvider
14
{
15
    protected $provides = [
16
        Client::class,
17
        Event::class,
18
        Service::class,
19
    ];
20
21 1
    public function register()
22
    {
23
        $this->getContainer()->share(Client::class, function () {
24 1
            $host = getenv('ETCD_SERVICE_HOST') ?: 'etcd';
25 1
            $port = getenv('ETCD_SERVICE_PORT') ?: 2379;
26 1
            return new Client("http://$host:$port");
27 1
        });
28
        $this->getContainer()->share(Event::class, function () {
29
            $dispatcher = $this->getContainer()->get(Dispatcher::class);
30
            $service = $this->getContainer()->get(Service::class);
31
            $spy = $this->getContainer()->get(Spy::class);
32
            return new Event($dispatcher, $service, $spy);
33 1
        });
34 1
        $this->getContainer()->share(Service::class, function () {
35
            $client = $this->getContainer()->get(Client::class);
36
            $config = $this->getContainer()->get(Config::class);
37
            return new Service($client, $config);
38 1
        });
39 1
    }
40
}
41