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
Pull Request — master (#159)
by Roman
01:49
created

Endpoint::getAlias()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

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