Completed
Push — master ( 4848aa...64d9da )
by Dmitry
03:44
created

ServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.156

Importance

Changes 4
Bugs 2 Features 0
Metric Value
dl 0
loc 16
ccs 6
cts 13
cp 0.4615
rs 9.4285
c 4
b 2
f 0
cc 1
eloc 11
nc 1
nop 0
crap 1.156
1
<?php
2
3
namespace Basis\Provider;
4
5
use Basis\Application;
6
use Basis\Config;
7
use Basis\Event;
8
use Basis\Filesystem;
9
use Basis\Service;
10
use League\Container\ServiceProvider\AbstractServiceProvider;
11
use Tarantool\Mapper\Pool;
12
13
class ServiceProvider extends AbstractServiceProvider
14
{
15
    protected $provides = [
16
        Event::class,
17
        Service::class,
18
    ];
19
20
    public function register()
21
    {
22 2
        $this->getContainer()->share(Event::class, function () {
23 2
            $app = $this->getContainer()->get(Application::class);
24 2
            $service = $this->getContainer()->get(Service::class);
25 2
            $pool = $this->getContainer()->get(Pool::class);
26 2
            $filesystem = $this->getContainer()->get(Filesystem::class);
27 2
            return new Event($app, $service, $pool, $filesystem);
28
        });
29
30
        $this->getContainer()->share(Service::class, function () {
31
            $config = $this->getContainer()->get(Config::class);
32
            $app = $this->getContainer()->get(Application::class);
33
            return new Service($config['service'], $app);
34
        });
35
    }
36
}
37