Completed
Push — master ( 772acc...7ea003 )
by Dmitry
11:15
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 52.94%

Importance

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

1 Method

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