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 ( cdf96f...74e120 )
by Cees-Jan
8s
created

CacheKey::stripExtraSlashes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
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
    public static function create(UriInterface $uri, string $glue): string
17
    {
18
        return self::stripExtraSlashes(
19
            implode(
20
                $glue,
21
                [
22
                    (string)$uri->getScheme(),
23
                    (string)$uri->getHost(),
24
                    (string)$uri->getPort(),
25
                    self::chunkUp(md5((string)$uri->getPath()), $glue),
26
                    self::chunkUp(md5((string)$uri->getQuery()), $glue),
27
                ]
28
            ),
29
            $glue
30
        );
31
    }
32
33
    /**
34
     * @param string $string
35
     * @param string $glue
36
     * @return string
37
     */
38
    private static function chunkUp(string $string, string $glue): string
39
    {
40
        return implode($glue, str_split($string, 2));
41
    }
42
43
    /**
44
     * @param string $string
45
     * @return string
46
     */
47
    private static function stripExtraSlashes(string $string, string $glue): string
48
    {
49
        return preg_replace('#' . $glue . '+#', $glue, $string);
50
    }
51
}
52