GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( ea7902...4799ee )
by Cees-Jan
20s
created

Mapping   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 78.26%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 3
dl 0
loc 40
ccs 18
cts 23
cp 0.7826
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 17 6
A gather() 0 19 3
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\CommandBus;
4
5
use PackageVersions\Versions;
6
use WyriHaximus\Tactician\CommandHandler\Mapper;
7
8
/**
9
 * @internal
10
 */
11
final class Mapping
12
{
13 2
    public static function resolve(iterable $directories, ?string $cacheFile): iterable
14
    {
15 2
        if ($cacheFile !== null && file_exists($cacheFile)) {
16
            $commandToHandlerMap = Cache::read($cacheFile);
17
            if (count($commandToHandlerMap) > 0) {
18
                return $commandToHandlerMap;
19
            }
20
        }
21
22 2
        $commandToHandlerMap = self::gather($directories);
23
24 2
        if ($cacheFile !== null && is_dir(dirname($cacheFile))) {
25
            Cache::write($cacheFile, $commandToHandlerMap);
0 ignored issues
show
Documentation introduced by
$commandToHandlerMap is of type object<Generator>, but the function expects a array.

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...
26
        }
27
28 2
        return $commandToHandlerMap;
29
    }
30
31 2
    private static function gather(iterable $directories): iterable
32
    {
33 2
        $mapperVersion = version_compare(
34 2
            explode(
35 2
                '@',
36 2
                Versions::getVersion('wyrihaximus/tactician-command-handler-mapper')
37 2
            )[0],
38 2
            '2.0.0',
39 2
            '<'
40
        );
41
42 2
        foreach ($directories as $path => $namespace) {
43 1
            $args = [$path];
44 1
            if ($mapperVersion) {
45
                $args[] = $namespace;
46
            }
47 1
            yield from Mapper::map(...$args);
0 ignored issues
show
Documentation introduced by
$args is of type array<integer,?>, but the function expects a string.

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...
48
        }
49 2
    }
50
}
51