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

Cache   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 11 3
A write() 0 8 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\CommandBus;
4
5
use ExceptionalJSON\DecodeErrorException;
6
use WyriHaximus\Tactician\CommandHandler\Annotations\Handler;
7
8
/**
9
 * @internal
10
 */
11
final class Cache
12
{
13 2
    public static function read(string $cacheFile): iterable
14
    {
15
        try {
16 2
            $mapping = json_try_decode(file_get_contents($cacheFile));
17 1
            foreach ($mapping as $command => $handler) {
18 1
                yield $command => new Handler($handler);
19
            }
20 1
        } catch (DecodeErrorException $decodeErrorException) {
21 1
            yield from [];
22
        }
23 2
    }
24
25 1
    public static function write(string $cacheFile, array $mapping): bool
26
    {
27
        return (bool)file_put_contents($cacheFile, json_encode(array_map(function (Handler $handler) {
28
            return [
29 1
                $handler->getHandler(),
30
            ];
31 1
        }, $mapping)));
32
    }
33
}
34