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.

Endpoint::getUrl()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 18
c 0
b 0
f 0
rs 9.2
ccs 14
cts 14
cp 1
cc 4
eloc 13
nc 4
nop 1
crap 4
1
<?php declare(strict_types=1);
2
3
namespace OpenStack\Identity\v2\Models;
4
5
use OpenStack\Common\HydratorStrategyTrait;
6
use OpenStack\Common\Resource\OperatorResource;
7
8
/**
9
 * Represents an Identity v2 catalog entry endpoint.
10
 *
11
 * @package OpenStack\Identity\v2\Models
12
 */
13
class Endpoint extends OperatorResource
14
{
15
    use HydratorStrategyTrait;
16
17
    /** @var string */
18
    public $adminUrl;
19
20
    /** @var string */
21
    public $region;
22
23
    /** @var string */
24
    public $internalUrl;
25
26
    /** @var string */
27
    public $publicUrl;
28
29
    protected $aliases = [
30
        'adminURL'    => 'adminUrl',
31
        'internalURL' => 'internalUrl',
32
        'publicURL'   => 'publicUrl',
33
    ];
34
35
    /**
36
     * Indicates whether a given region is supported
37
     *
38
     * @param string $region
39
     *
40
     * @return bool
41
     */
42 1
    public function supportsRegion(string $region): bool
43
    {
44 1
        return $this->region == $region;
45
    }
46
47
    /**
48
     * Indicates whether a given URL type is supported
49
     *
50
     * @param string $urlType
51
     *
52
     * @return bool
53
     */
54 1
    public function supportsUrlType(string $urlType): bool
55
    {
56 1
        $supported = false;
57
58 1
        switch (strtolower($urlType)) {
59 1
            case 'internalurl':
60 1
            case 'publicurl':
61 1
            case 'adminurl':
62 1
                $supported = true;
63 1
                break;
64 1
        }
65
66 1
        return $supported;
67
    }
68
69
    /**
70
     * Retrieves a URL for the endpoint based on a specific type.
71
     *
72
     * @param string $urlType Either "internalURL", "publicURL" or "adminURL" (case insensitive)
73
     *
74
     * @return bool|string
75
     */
76 3
    public function getUrl(string $urlType): string
77
    {
78 3
        $url = false;
79
80 3
        switch (strtolower($urlType)) {
81 3
            case 'internalurl':
82 1
                $url = $this->internalUrl;
83 1
                break;
84 2
            case 'publicurl':
85 1
                $url = $this->publicUrl;
86 1
                break;
87 1
            case 'adminurl':
88 1
                $url = $this->adminUrl;
89 1
                break;
90 3
        }
91
92 3
        return $url;
93
    }
94
}
95