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

CoreProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 25%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
wmc 1
lcom 0
cbo 7
dl 0
loc 37
ccs 5
cts 20
cp 0.25
rs 10
c 2
b 2
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 26 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
        $this->getContainer()->share(Config::class, function () {
28
            $framework = $this->getContainer()->get(Framework::class);
29
            $fs = $this->getContainer()->get(Filesystem::class);
30
            $converter = $this->getContainer()->get(Converter::class);
31
            return new Config($framework, $fs, $converter);
32
        });
33
34
        $this->getContainer()->share(Converter::class, function () {
35
            return new Converter();
36
        });
37
38 1
        $this->getContainer()->share(Dispatcher::class, function () {
39 1
            $client = $this->getContainer()->get(Client::class);
40 1
            return new Dispatcher($client);
41
        });
42
43
        $this->getContainer()->share(Framework::class, function () {
44
            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
        });
46
47 1
        $this->getContainer()->share(Http::class, function () {
48 1
            return new Http($this->getContainer()->get(Application::class));
49
        });
50
    }
51
}
52