Passed
Push — 1.0 ( 12d132...dd1957 )
by Vladimir
06:10
created

ContextServiceProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 23
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Conversation\Providers;
6
7
use FondBot\Contracts\Cache;
8
use FondBot\Conversation\ContextManager;
9
use League\Container\ServiceProvider\AbstractServiceProvider;
10
11
class ContextServiceProvider extends AbstractServiceProvider
12
{
13
    protected $provides = [
14
        ContextManager::class,
15
    ];
16
17
    /**
18
     * Use the register method to register items with the container via the
19
     * protected $this->container property or the `getContainer` method
20
     * from the ContainerAwareTrait.
21
     *
22
     * @return void
23
     */
24
    public function register(): void
25
    {
26
        $manager = new ContextManager(
27
            $this->getContainer(),
0 ignored issues
show
Compatibility introduced by
$this->getContainer() of type object<League\Container\ContainerInterface> is not a sub-type of object<FondBot\Application\Container>. 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...
28
            $this->getContainer()->get(Cache::class)
29
        );
30
31
        $this->getContainer()->add(ContextManager::class, $manager);
32
    }
33
}
34