Passed
Push — master ( 922d24...7b732c )
by Vladimir
06:12
created

DriverServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 19 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Drivers;
6
7
use FondBot\Application\Assets;
8
use League\Container\ServiceProvider\AbstractServiceProvider;
9
10
class DriverServiceProvider extends AbstractServiceProvider
11
{
12
    protected $provides = [
13
        DriverManager::class,
14
    ];
15
16
    /**
17
     * Use the register method to register items with the container via the
18
     * protected $this->container property or the `getContainer` method
19
     * from the ContainerAwareTrait.
20
     *
21
     * @return void
22
     *
23
     * @throws \Psr\Container\ContainerExceptionInterface
24
     */
25
    public function register(): void
26
    {
27 1
        $this->container->share(DriverManager::class, function () {
28
            // Here we will discover all drivers installed
29
            // And add all found drivers to the manager
30
31 1
            $manager = new DriverManager($this->container);
0 ignored issues
show
Unused Code introduced by
The call to DriverManager::__construct() has too many arguments starting with $this->container.

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...
32
            /** @var Assets $assetLoader */
33 1
            $assetLoader = $this->container->get(Assets::class);
34
35 1
            $assets = $assetLoader->discover('driver');
36
37 1
            foreach ($assets as $asset) {
38 1
                $manager->add($this->container->get($asset));
39
            }
40
41 1
            return $manager;
42 1
        });
43 1
    }
44
}
45