Completed
Push — master ( 382c80...0287cb )
by Dmitry
04:23
created

EtcdProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 21
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 13 3
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 1
    public function register()
18
    {
19
        $this->getContainer()->share(Client::class, function () {
20 1
            $host = getenv('ETCD_SERVICE_HOST') ?: 'etcd';
21 1
            $port = getenv('ETCD_SERVICE_PORT') ?: 2379;
22 1
            return new Client("http://$host:$port");
23 1
        });
24 1
        $this->getContainer()->share(Etcd::class, function () {
25
            $client = $this->getContainer()->get(Client::class);
26
            $config = $this->getContainer()->get(Config::class);
27
            return new Etcd($client, $config);
28 1
        });
29 1
    }
30
}
31