Completed
Push — master ( 9ff9d7...8b6791 )
by Dmitry
03:09
created

Logging::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1.008

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 8
cts 10
cp 0.8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 1.008
1
<?php
2
3
namespace Basis\Providers;
4
5
use Basis\Config;
6
use Basis\Logger;
7
use Fluent\Logger\FluentLogger;
8
use League\Container\ServiceProvider\AbstractServiceProvider;
9
10
class Logging extends AbstractServiceProvider
11
{
12
    protected $provides = [
13
        FluentLogger::class,
14
        Logger::class,
15
    ];
16
17 1
    public function register()
18
    {
19
        $this->container->share(FluentLogger::class, function() {
20
            $config = $this->container->get(Config::class);
21
            return new FluentLogger($config['fluent.host'], $config['fluent.port']);
22 1
        });
23
24 1
        $this->container->share(Logger::class, function() {
25 1
            $fluent = $this->container->get(FluentLogger::class);
26 1
            $config = $this->container->get(Config::class);
27 1
            return new Logger($fluent, $config['app.name']);
28 1
        });
29
30
    }
31
}