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.

functions.php ➔ realmConfiguration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 19
ccs 0
cts 11
cp 0
crap 2
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
namespace WyriHaximus\Ratchet;
4
5
use Cake\Core\Configure;
6
use React\EventLoop\Factory;
7
use React\EventLoop\LoopInterface;
8
use PipingBag\Di\PipingBag;
9
10
/**
11
 * @return LoopInterface
12
 */
13
function loopResolver()
14
{
15
    if (
16
        Configure::check('WyriHaximus.Ratchet.loop') &&
17
        Configure::read('WyriHaximus.Ratchet.loop') instanceof LoopInterface
18
    ) {
19
        return Configure::read('WyriHaximus.Ratchet.loop');
20
    }
21
22
    if (class_exists('PipingBag\Di\PipingBag') && Configure::check('WyriHaximus.Ratchet.pipingbag.loop')) {
23
        return PipingBag::get(Configure::read('WyriHaximus.Ratchet.pipingbag.loop'));
24
    }
25
26
    return Factory::create();
27
}
28
29
/**
30
 * @param string $realm
31
 * @return array
32
 */
33
function realmConfiguration($realm)
34
{
35
    $defaults = [
36
        'secure' => false,
37
    ];
38
39
    $options = array_merge(
40
        $defaults,
41
        Configure::read('WyriHaximus.Ratchet.realms.' . $realm),
42
        Configure::read('WyriHaximus.Ratchet.external')
43
    );
44
45
    $config = [
46
        'realm' => $realm,
47
        'url' => createUrl($options['secure'], $options['hostname'], $options['port'], $options['path']),
48
    ];
49
50
    return array_merge($options['config'], $config);
51
}
52
53
/**
54
 * @param boolean $secure
55
 * @param string $hostname
56
 * @param integer $port
57
 * @param string $path
58
 * @return string
59
 */
60
function createUrl($secure, $hostname, $port, $path)
61
{
62 5
    $url = 'ws';
63 5
    if ($secure) {
64 3
        $url .= 's';
65 3
    }
66 5
    $url .= '://';
67
68 5
    $url .= $hostname;
69
70
    if (
71 5
        !($port == 80 && !$secure) &&
72 4
        !($port == 443 && $secure)
73 5
    ) {
74 3
        $url .= ':';
75 3
        $url .= $port;
76 3
    }
77
78 5
    $url .= '/';
79 5
    $url .= ltrim($path, '/');
80
81 5
    return $url;
82
}
83