Completed
Push — master ( 7ea003...b9e0e5 )
by Dmitry
03:31
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

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

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 2
        $this->getContainer()->share(Client::class, function () {
25 2
            $host = getenv('ETCD_SERVICE_HOST') ?: 'etcd';
26 2
            $port = getenv('ETCD_SERVICE_PORT') ?: 2379;
27 2
            return new Client("http://$host:$port");
28 2
        });
29 2
        $this->getContainer()->share(Event::class, function () {
30 1
            $dispatcher = $this->getContainer()->get(Dispatcher::class);
31 1
            $service = $this->getContainer()->get(Service::class);
32 1
            $spy = $this->getContainer()->get(Spy::class);
33 1
            $filesystem = $this->getContainer()->get(Filesystem::class);
34 1
            return new Event($dispatcher, $service, $spy, $filesystem);
35 2
        });
36 2
        $this->getContainer()->share(Service::class, function () {
37 1
            $client = $this->getContainer()->get(Client::class);
38 1
            $config = $this->getContainer()->get(Config::class);
39 1
            return new Service($client, $config);
40 2
        });
41
    }
42
}
43