Completed
Push — master ( 1f1a8e...ab56b8 )
by Dmitry
03:54
created

CoreProvider::register()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 20
CRAP Score 1

Importance

Changes 2
Bugs 2 Features 0
Metric Value
dl 0
loc 26
ccs 20
cts 20
cp 1
rs 8.8571
c 2
b 2
f 0
cc 1
eloc 15
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Basis\Provider;
4
5
use Basis\Application;
6
use Basis\Config;
7
use Basis\Converter;
8
use Basis\Dispatcher;
9
use Basis\Filesystem;
10
use Basis\Framework;
11
use Basis\Http;
12
use GuzzleHttp\Client;
13
use League\Container\ServiceProvider\AbstractServiceProvider;
14
15
class CoreProvider extends AbstractServiceProvider
16
{
17
    protected $provides = [
18
        Config::class,
19
        Converter::class,
20
        Dispatcher::class,
21
        Framework::class,
22
        Http::class,
23
    ];
24
25
    public function register()
26
    {
27 37
        $this->getContainer()->share(Config::class, function () {
28 37
            $framework = $this->getContainer()->get(Framework::class);
29 37
            $fs = $this->getContainer()->get(Filesystem::class);
30 37
            $converter = $this->getContainer()->get(Converter::class);
31 37
            return new Config($framework, $fs, $converter);
32 22
        });
33
34 22
        $this->getContainer()->share(Converter::class, function () {
35 22
            return new Converter();
36 22
        });
37
38 22
        $this->getContainer()->share(Dispatcher::class, function () {
39 1
            $client = $this->getContainer()->get(Client::class);
40 1
            return new Dispatcher($client);
41 22
        });
42
43 37
        $this->getContainer()->share(Framework::class, function () {
44 37
            return new Framework($this->getContainer(), dirname(dirname(__DIR__)));
0 ignored issues
show
Compatibility introduced by
$this->getContainer() of type object<League\Container\ContainerInterface> is not a sub-type of object<Basis\Application>. It seems like you assume a concrete implementation of the interface League\Container\ContainerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
45 22
        });
46
47 22
        $this->getContainer()->share(Http::class, function () {
48 1
            return new Http($this->getContainer()->get(Application::class));
49 22
        });
50 22
    }
51
}
52