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

CoreProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 94.74%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 1
lcom 0
cbo 7
dl 0
loc 36
ccs 18
cts 19
cp 0.9474
rs 10
c 2
b 2
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 25 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 League\Container\ServiceProvider\AbstractServiceProvider;
13
14
class CoreProvider extends AbstractServiceProvider
15
{
16
    protected $provides = [
17
        Config::class,
18
        Converter::class,
19
        Dispatcher::class,
20
        Framework::class,
21
        Http::class,
22
    ];
23
24
    public function register()
25
    {
26 21
        $this->getContainer()->share(Config::class, function () {
27 21
            $framework = $this->getContainer()->get(Framework::class);
28 21
            $fs = $this->getContainer()->get(Filesystem::class);
29 21
            $converter = $this->getContainer()->get(Converter::class);
30 21
            return new Config($framework, $fs, $converter);
31 21
        });
32
33 21
        $this->getContainer()->share(Converter::class, function () {
34 21
            return new Converter();
35 21
        });
36
37 21
        $this->getContainer()->share(Dispatcher::class, function () {
38
            return new Dispatcher();
39 21
        });
40
41 21
        $this->getContainer()->share(Framework::class, function () {
42 21
            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...
43 21
        });
44
45 21
        $this->getContainer()->share(Http::class, function () {
46 1
            return new Http($this->getContainer()->get(Application::class));
47 21
        });
48 21
    }
49
}
50