Completed
Push — master ( 346e09...46a5ae )
by Dmitry
06:10
created

EtcdProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 1
1
<?php
2
3
namespace Basis\Providers;
4
5
use Basis\Config;
6
use Basis\Etcd;
7
use League\Container\ServiceProvider\AbstractServiceProvider;
8
use LinkORB\Component\Etcd\Client;
9
10
class EtcdProvider extends AbstractServiceProvider
11
{
12
    protected $provides = [
13
        Client::class,
14
        Etcd::class,
15
    ];
16
17
    public function register()
18
    {
19
        $this->getContainer()->share(Client::class, function () {
20
            return new Client('http://'.getenv('ETCD_SERVICE_HOST').':'.getenv('ETCD_SERVICE_PORT'));
21
        });
22
        $this->getContainer()->share(Etcd::class, function () {
23
            $client = $this->getContainer()->get(Client::class);
24
            $config = $this->getContainer()->get(Config::class);
25
            return new Etcd($client, $config);
26
        });
27
    }
28
}
29