Completed
Push — master ( 72ab7d...a27e2e )
by Dmitry
03:03
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

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 14
ccs 8
cts 8
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
crap 1
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
}