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.

ApiSettings   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 45
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getVersion() 0 14 3
A createUrl() 0 15 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Pusher;
4
5
use Jean85\PrettyVersions;
6
7
final class ApiSettings
8
{
9
    /**
10
     * Create Pusher compatible version.
11
     *
12
     * @param  string $version
13
     * @return string
14
     */
15 9
    public static function getVersion(string $version = ''): string
16
    {
17 9
        if ($version === '') {
18 6
            $version = PrettyVersions::getVersion('api-clients/pusher')->getFullVersion();
19
        }
20
21 9
        list($version, $hash) = \explode('@', $version);
22
23 9
        if (\strpos($version, 'dev') !== false) {
24 8
            return '0.0.1-' . $hash;
25
        }
26
27 1
        return $version;
28
    }
29
30
    /**
31
     * Create WebSocket URL for given App ID.
32
     *
33
     * @param  string $appId
34
     * @return string
35
     */
36 5
    public static function createUrl(string $appId, string $cluster = null): string
37
    {
38
        $query = [
39 5
            'client' => 'api-clients/pusher (https://php-api-clients.org/clients/pusher)',
40 5
            'protocol' => 7,
41 5
            'version' => ApiSettings::getVersion(),
42
        ];
43
44 5
        $host = ($cluster !== null) ? "ws-{$cluster}.pusher.com" : 'ws.pusherapp.com';
45
46 5
        return 'wss://'.$host.'/app/' .
47 5
            $appId .
48 5
            '?' . \http_build_query($query)
49
        ;
50
    }
51
}
52