Completed
Push — master ( b663ee...50d896 )
by Dmitry
06:21
created

ServiceProvider::register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1.0568

Importance

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