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
Pull Request — master (#15)
by Cees-Jan
10:52 queued 53s
created

Mapping::gather()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
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
    public static function resolve(array $directories, ?string $cacheFile): iterable
13
    {
14
        if ($cacheFile !== null && file_exists($cacheFile)) {
15
            $commandToHandlerMap = Cache::read($cacheFile);
16
            if (count($commandToHandlerMap) > 0) {
17
                return $commandToHandlerMap;
18
            }
19
        }
20
21
        $commandToHandlerMap = self::gather($directories);
22
23
        if ($cacheFile !== null && is_dir(dirname($cacheFile))) {
24
            Cache::write($cacheFile, $commandToHandlerMap);
25
        }
26
27
        return $commandToHandlerMap;
28
    }
29
30
    private static function gather(array $directories): iterable
31
    {
32
        $map = [];
33
        foreach ($directories as $path => $namespace) {
34
            $map += Mapper::map($path, $namespace);
35
        }
36
37
        return $map;
38
    }
39
}
40