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::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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