Completed
Push — master ( 35c8bf...601de6 )
by Dmitry
04:42 queued 01:15
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 56.25%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 5
dl 0
loc 28
ccs 9
cts 16
cp 0.5625
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\Event;
7
use Basis\Service;
8
use League\Container\ServiceProvider\AbstractServiceProvider;
9
use LinkORB\Component\Etcd\Client;
10
use Tarantool\Mapper\Plugins\Spy;
11
12
class ServiceProvider extends AbstractServiceProvider
13
{
14
    protected $provides = [
15
        Client::class,
16
        Event::class,
17
        Service::class,
18
    ];
19
20 1
    public function register()
21
    {
22
        $this->getContainer()->share(Client::class, function () {
23 1
            $host = getenv('ETCD_SERVICE_HOST') ?: 'etcd';
24 1
            $port = getenv('ETCD_SERVICE_PORT') ?: 2379;
25 1
            return new Client("http://$host:$port");
26 1
        });
27
        $this->getContainer()->share(Event::class, function () {
28
            $dispatcher = $this->getContainer()->get(Dispatcher::class);
29
            $config = $this->getContainer()->get(Config::class);
30
            $spy = $this->getContainer()->get(Spy::class);
31
            return new Event($dispatcher, $config, $spy);
32 1
        });
33 1
        $this->getContainer()->share(Service::class, function () {
34
            $client = $this->getContainer()->get(Client::class);
35
            $config = $this->getContainer()->get(Config::class);
36
            return new Service($client, $config);
37 1
        });
38 1
    }
39
}
40