Completed
Push — master ( 772acc...7ea003 )
by Dmitry
11:15
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.44%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 25 1
1
<?php
2
3
namespace Basis\Provider;
4
5
use Basis\Config;
6
use Basis\Converter;
7
use Basis\Dispatcher;
8
use Basis\Filesystem;
9
use Basis\Framework;
10
use Basis\Http;
11
use League\Container\ServiceProvider\AbstractServiceProvider;
12
use LinkORB\Component\Etcd\Client;
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 8
        $this->getContainer()->share(Config::class, function () {
27 7
            $framework = $this->getContainer()->get(Framework::class);
28 7
            $fs = $this->getContainer()->get(Filesystem::class);
29 7
            $converter = $this->getContainer()->get(Converter::class);
30 7
            return new Config($framework, $fs, $converter);
31 8
        });
32
33 8
        $this->getContainer()->share(Converter::class, function () {
34 8
            return new Converter();
35 8
        });
36
37 8
        $this->getContainer()->share(Dispatcher::class, function () {
38
            return new Dispatcher($this->getContainer()->get(Client::class));
39 8
        });
40
41 8
        $this->getContainer()->share(Framework::class, function () {
42 7
            return new Framework($this->getContainer());
0 ignored issues
show
Unused Code introduced by
The call to Framework::__construct() has too many arguments starting with $this->getContainer().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
43 8
        });
44
45 8
        $this->getContainer()->share(Http::class, function () {
46 1
            return new Http($this->getContainer());
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...
47 8
        });
48
    }
49
}
50