ContainerAwareEventBusFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 22
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A make() 0 19 3
1
<?php
2
declare(strict_types = 1);
3
4
namespace Innmind\EventBusBundle\Factory;
5
6
use Innmind\EventBusBundle\ContainerAwareEventBus;
7
use Innmind\EventBus\ClassName\ExtractorInterface;
8
use Innmind\Immutable\{
9
    Map,
10
    SetInterface,
11
    Set
12
};
13
use Symfony\Component\DependencyInjection\ContainerInterface;
14
15
final class ContainerAwareEventBusFactory
16
{
17 3
    public static function make(
18
        ContainerInterface $container,
19
        array $services,
20
        ExtractorInterface $extractor
21
    ): ContainerAwareEventBus {
22 3
        $map = new Map('string', SetInterface::class);
23
24 3
        foreach ($services as $class => $listeners) {
25 3
            $set = new Set('string');
26
27 3
            foreach ($listeners as $listener) {
28 3
                $set = $set->add($listener);
29
            }
30
31 3
            $map = $map->put($class, $set);
2 ignored issues
show
Documentation introduced by
$class is of type integer|string, but the function expects a object<Innmind\Immutable\T>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$set is of type object<Innmind\Immutable\Set>, but the function expects a object<Innmind\Immutable\S>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
32
        }
33
34 3
        return new ContainerAwareEventBus($container, $map, $extractor);
35
    }
36
}
37