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.

CacheKey   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 45
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 16 1
A chunkUp() 0 4 1
A stripExtraSlashes() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Middleware\Cache;
4
5
use Psr\Http\Message\UriInterface;
6
7
final class CacheKey
8
{
9
    /**
10
     * Create a cache key based on the URI and glue.
11
     *
12
     * @param  UriInterface $uri
13
     * @param  string       $glue
14
     * @return string
15
     */
16 6
    public static function create(UriInterface $uri, string $glue): string
17
    {
18 6
        return self::stripExtraSlashes(
19 6
            \implode(
20 6
                $glue,
21
                [
22 6
                    (string)$uri->getScheme(),
23 6
                    (string)$uri->getHost(),
24 6
                    (string)$uri->getPort(),
25 6
                    self::chunkUp(\md5((string)$uri->getPath()), $glue),
26 6
                    self::chunkUp(\md5((string)$uri->getQuery()), $glue),
27
                ]
28
            ),
29 6
            $glue
30
        );
31
    }
32
33
    /**
34
     * @param  string $string
35
     * @param  string $glue
36
     * @return string
37
     */
38 6
    private static function chunkUp(string $string, string $glue): string
39
    {
40 6
        return \implode($glue, \str_split($string, 2));
41
    }
42
43
    /**
44
     * @param  string $string
45
     * @return string
46
     */
47 6
    private static function stripExtraSlashes(string $string, string $glue): string
48
    {
49 6
        return \preg_replace('#' . $glue . '+#', $glue, $string);
50
    }
51
}
52