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 ( 53fb33...90de41 )
by Cees-Jan
24s
created

Mapping::resolve()   A

Complexity

Conditions 6
Paths 5

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 9.1595

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 5
cts 9
cp 0.5556
rs 9.0777
c 0
b 0
f 0
cc 6
nc 5
nop 2
crap 9.1595
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\CommandBus;
4
5
use WyriHaximus\Tactician\CommandHandler\Mapper;
6
7
/**
8
 * @internal
9
 */
10
final class Mapping
11
{
12 1
    public static function resolve(iterable $directories, ?string $cacheFile): iterable
13
    {
14 1
        if ($cacheFile !== null && file_exists($cacheFile)) {
15
            $commandToHandlerMap = Cache::read($cacheFile);
16
            if (count($commandToHandlerMap) > 0) {
17
                return $commandToHandlerMap;
18
            }
19
        }
20
21 1
        $commandToHandlerMap = self::gather($directories);
22
23 1
        if ($cacheFile !== null && is_dir(dirname($cacheFile))) {
24
            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...
25
        }
26
27 1
        return $commandToHandlerMap;
28
    }
29
30 1
    private static function gather(iterable $directories): iterable
31
    {
32 1
        foreach ($directories as $path => $namespace) {
33
            yield from Mapper::map($path, $namespace);
34
        }
35 1
    }
36
}
37